@@ -1008,6 +1008,86 @@ public function notSameAs($field, $secondField, $message = null, $when = null)
1008
1008
]);
1009
1009
}
1010
1010
1011
+ /**
1012
+ * Add a rule to compare one field is greater than another.
1013
+ *
1014
+ * @param mixed $field The field you want to apply the rule to.
1015
+ * @param mixed $secondField The field you want to compare against.
1016
+ * @param string|null $message The error message when the rule fails.
1017
+ * @param string|callable|null $when Either 'create' or 'update' or a callable that returns
1018
+ * true when the validation rule should be applied.
1019
+ * @see \Cake\Validation\Validation::compareFields()
1020
+ * @return $this
1021
+ */
1022
+ public function greaterThanField ($ field , $ secondField , $ message = null , $ when = null )
1023
+ {
1024
+ $ extra = array_filter (['on ' => $ when , 'message ' => $ message ]);
1025
+
1026
+ return $ this ->add ($ field , 'greaterThanField ' , $ extra + [
1027
+ 'rule ' => ['compareFields ' , $ secondField , '> ' ]
1028
+ ]);
1029
+ }
1030
+
1031
+ /**
1032
+ * Add a rule to compare one field is greater than or equal to another.
1033
+ *
1034
+ * @param mixed $field The field you want to apply the rule to.
1035
+ * @param mixed $secondField The field you want to compare against.
1036
+ * @param string|null $message The error message when the rule fails.
1037
+ * @param string|callable|null $when Either 'create' or 'update' or a callable that returns
1038
+ * true when the validation rule should be applied.
1039
+ * @see \Cake\Validation\Validation::compareFields()
1040
+ * @return $this
1041
+ */
1042
+ public function greaterThanOrEqualToField ($ field , $ secondField , $ message = null , $ when = null )
1043
+ {
1044
+ $ extra = array_filter (['on ' => $ when , 'message ' => $ message ]);
1045
+
1046
+ return $ this ->add ($ field , 'greaterThanOrEqualToField ' , $ extra + [
1047
+ 'rule ' => ['compareFields ' , $ secondField , '>= ' ]
1048
+ ]);
1049
+ }
1050
+
1051
+ /**
1052
+ * Add a rule to compare one field is less than another.
1053
+ *
1054
+ * @param mixed $field The field you want to apply the rule to.
1055
+ * @param mixed $secondField The field you want to compare against.
1056
+ * @param string|null $message The error message when the rule fails.
1057
+ * @param string|callable|null $when Either 'create' or 'update' or a callable that returns
1058
+ * true when the validation rule should be applied.
1059
+ * @see \Cake\Validation\Validation::compareFields()
1060
+ * @return $this
1061
+ */
1062
+ public function lessThanField ($ field , $ secondField , $ message = null , $ when = null )
1063
+ {
1064
+ $ extra = array_filter (['on ' => $ when , 'message ' => $ message ]);
1065
+
1066
+ return $ this ->add ($ field , 'lessThanField ' , $ extra + [
1067
+ 'rule ' => ['compareFields ' , $ secondField , '< ' ]
1068
+ ]);
1069
+ }
1070
+
1071
+ /**
1072
+ * Add a rule to compare one field is less than or equal to another.
1073
+ *
1074
+ * @param mixed $field The field you want to apply the rule to.
1075
+ * @param mixed $secondField The field you want to compare against.
1076
+ * @param string|null $message The error message when the rule fails.
1077
+ * @param string|callable|null $when Either 'create' or 'update' or a callable that returns
1078
+ * true when the validation rule should be applied.
1079
+ * @see \Cake\Validation\Validation::compareFields()
1080
+ * @return $this
1081
+ */
1082
+ public function lessThanOrEqualToField ($ field , $ secondField , $ message = null , $ when = null )
1083
+ {
1084
+ $ extra = array_filter (['on ' => $ when , 'message ' => $ message ]);
1085
+
1086
+ return $ this ->add ($ field , 'lessThanOrEqualToField ' , $ extra + [
1087
+ 'rule ' => ['compareFields ' , $ secondField , '<= ' ]
1088
+ ]);
1089
+ }
1090
+
1011
1091
/**
1012
1092
* Add a rule to check if a field contains non alpha numeric characters.
1013
1093
*
0 commit comments