@@ -40,16 +40,21 @@ public function validationDomain(?string $domain = null): ?string
4040 * @param \Cake\Validation\ValidationSet $rules the list of rules for a field
4141 * @param array $data the full data passed to the validator
4242 * @param bool $newRecord whether is it a new record or an existing one
43+ * @param array $context Additional validation context.
4344 * @return array<string, mixed>
4445 */
45- protected function _processRules (string $ field , ValidationSet $ rules , array $ data , bool $ newRecord ): array
46- {
46+ protected function _processRules (
47+ string $ field ,
48+ ValidationSet $ rules ,
49+ array $ data ,
50+ bool $ newRecord ,
51+ array $ context = [],
52+ ): array {
4753 $ errors = [];
48- // Loading default provider in case there is none
49- $ this ->getProvider ('default ' );
54+ $ context = compact ('newRecord ' , 'data ' , 'field ' ) + $ context ;
5055
5156 foreach ($ rules as $ name => $ rule ) {
52- $ result = $ rule ->process ($ data [$ field ], $ this ->_providers , compact ( ' newRecord ' , ' data ' , ' field ' ) );
57+ $ result = $ rule ->process ($ data [$ field ], $ this ->_providers , $ context );
5358 if ($ result === true ) {
5459 continue ;
5560 }
@@ -61,6 +66,10 @@ protected function _processRules(string $field, ValidationSet $rules, array $dat
6166 } else {
6267 $ args = $ rule ->get ('pass ' );
6368 $ errors [$ name ] = __d ($ this ->_validationDomain , $ name , $ this ->_translateArgs ($ args ));
69+
70+ if ($ errors [$ name ] === $ name ) {
71+ $ errors [$ name ] = __d ('cake ' , 'The provided value is invalid ' );
72+ }
6473 }
6574
6675 if ($ rule ->isLast ()) {
0 commit comments