-
-
Notifications
You must be signed in to change notification settings - Fork 151
Closed
Description
Version: v2.4.x-dev, v3.0.x-dev
Bug Description
PATTERN validator fails on controls that return object values, even if they are castable to string.
Steps To Reproduce
$control = new Nette\Forms\Controls\TextInput;
$control->setValue(new class () {private $lorem = 'ipsum'; function __toString() {return '142';}});
var_dump(Nette\Forms\Validator::validatePattern($control, '\d+')); // falseExpected Behavior
Validation should pass.
Possible Solution
The root cause is in Validator::toArray() method (which is called from Validator::validatePattern()) - it casts the object to array, which leads to some unexpected results. Validator::toArray() should not use array cast on objects.
Metadata
Metadata
Assignees
Labels
No labels