@@ -219,6 +219,10 @@ export default {
219219 type: Boolean ,
220220 default : () => getDefault (' validCharactersOnly' ),
221221 },
222+ customValidate: {
223+ type: [Boolean , RegExp ],
224+ default : () => getDefault (' customValidate' ),
225+ },
222226 dynamicPlaceholder: {
223227 type: Boolean ,
224228 default : () => getDefault (' dynamicPlaceholder' ),
@@ -319,7 +323,9 @@ export default {
319323 }
320324 },
321325 phone (newValue , oldValue ) {
322- if (this .validCharactersOnly && ! this .testCharacters ()) {
326+ const isValidCharactersOnly = this .validCharactersOnly && ! this .testCharacters ();
327+ const isCustomValidate = this .customValidate && ! this .testCustomValidate ();
328+ if (isValidCharactersOnly || isCustomValidate) {
323329 this .$nextTick (() => { this .phone = oldValue; });
324330 } else if (newValue) {
325331 if (newValue[0 ] === ' +' ) {
@@ -466,10 +472,16 @@ export default {
466472 const re = / ^ [()\-+0-9 \s ] * $ / ;
467473 return re .test (this .phone );
468474 },
475+ testCustomValidate () {
476+ return this .customValidate instanceof RegExp ? this .customValidate .test (this .phone ) : false ;
477+ },
469478 onInput (e ) {
470479 if (this .validCharactersOnly && ! this .testCharacters ()) {
471480 return ;
472481 }
482+ if (this .customValidate && ! this .testCustomValidate ()) {
483+ return ;
484+ }
473485 this .$refs .input .setCustomValidity (this .phoneObject .valid ? ' ' : this .invalidMsg );
474486 // Returns response.number to assign it to v-model (if being used)
475487 // Returns full response for cases @input is used
0 commit comments