Open vjik opened 5 months ago
In rule handlers Result::addError() is added error message to current key and value path define path into key. Need ability to add error with globally path.
Result::addError()
Example:
$result = (new Validator())->validate( data: ['a' => 1, 'b' => 2], rules: [ 'a' => new Callback(function(){ $result = new Result(); $result->addError('message', valuePath: ['b']); return $result; }) ], ); // Errors: // ['a.b' => ['message']]
Need additional ability add error to key b. May be implement it via adding method addError() to validation context object.
b
addError()
What's the use-case?
Forms: add error to another field or add error without fields (common errors).
In rule handlers
Result::addError()
is added error message to current key and value path define path into key. Need ability to add error with globally path.Example:
Need additional ability add error to key
b
. May be implement it via adding methodaddError()
to validation context object.