@@ -275,7 +275,8 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
275
275
RULE_ZIP = 'zip' ,
276
276
RULE_PHONE = 'phone' ,
277
277
RULE_REMOTE = 'remote' ,
278
- RULE_STRENGTH = 'strength' ;
278
+ RULE_STRENGTH = 'strength' ,
279
+ RULE_FUNCTION = 'function' ;
279
280
280
281
var formatParams = function formatParams ( params , method ) {
281
282
if ( typeof params === 'string' ) {
@@ -399,7 +400,8 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
399
400
minLength : 'The field must contain a minimum of :value characters' ,
400
401
password : 'Password is not valid' ,
401
402
remote : 'Email already exists' ,
402
- strength : 'Password must contents at least one uppercase letter, one lowercase letter and one number'
403
+ strength : 'Password must contents at least one uppercase letter, one lowercase letter and one number' ,
404
+ function : 'Function returned false'
403
405
} ,
404
406
/**
405
407
* Keyup handler
@@ -791,10 +793,21 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
791
793
for ( var rule in rules ) {
792
794
var ruleValue = rules [ rule ] ;
793
795
794
- if ( rule !== RULE_REQUIRED && value == '' ) {
796
+ if ( rule !== RULE_REQUIRED && rule !== RULE_FUNCTION && value == '' ) {
795
797
return ;
796
798
}
797
799
switch ( rule ) {
800
+ case RULE_FUNCTION :
801
+ {
802
+ if ( typeof ruleValue !== 'function' ) {
803
+ break ;
804
+ }
805
+ if ( ruleValue ( name , value ) ) {
806
+ break ;
807
+ }
808
+ this . generateMessage ( RULE_FUNCTION , name , ruleValue ) ;
809
+ return ;
810
+ }
798
811
case RULE_REQUIRED :
799
812
{
800
813
if ( ! ruleValue ) {
@@ -1054,7 +1067,6 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
1054
1067
$elems [ i ] . style . filter = '' ;
1055
1068
}
1056
1069
}
1057
-
1058
1070
} ;
1059
1071
1060
1072
window . JustValidate = JustValidate ;
0 commit comments