You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Since 1592cf6, no rules after a callback rule are passed to the frontend.
I understand that this is to prevent conflict between filters (which are just impure rules) and other rules but it leads to confusing behaviour, where rules suddenly terminate from frontend point of view, even if the callback is just a pure function.
Steps To Reproduce
test('', function () {
$form = new Form;
$input = $form->addText('text');
$input->addRule(function ($input) {
return true;
});
$input->addRule(Form::EMAIL);
Assert::same([
['op' => ':email', 'msg' => 'Please enter a valid email address.'],
], Helpers::exportRules($input->getRules()));
});
Expected Behavior
I think we should give callbacks passed to addRule a benefit of a doubt (that they might be pure) and not terminate the rule export.
But yeah, I understand the paranoid point of view (all functions are potentially effectful/impure and we cannot trust them not to modify the control) since PHP cannot distinguish pure and effectful functions.
Possible Solutions
We could add isFilter/impure property to Rule, set it to true in addFilter, and terminate export only for impure rules.
The behaviour could be further emphasised in docs and the hack would be recommended:
Due to this extremely confusing change, client side validation for custom rules on category field got broken:
nette/forms@1592cf6
Let’s apply the hack from the commit.
Opened an issue: nette/forms#278
Version: 3.1.3
Bug Description
Since 1592cf6, no rules after a callback rule are passed to the frontend.
I understand that this is to prevent conflict between filters (which are just impure rules) and other rules but it leads to confusing behaviour, where rules suddenly terminate from frontend point of view, even if the callback is just a pure function.
Steps To Reproduce
Expected Behavior
I think we should give callbacks passed to
addRule
a benefit of a doubt (that they might be pure) and not terminate the rule export.But yeah, I understand the paranoid point of view (all functions are potentially effectful/impure and we cannot trust them not to modify the control) since PHP cannot distinguish pure and effectful functions.
Possible Solutions
isFilter
/impure
property toRule
, set it totrue
inaddFilter
, and terminate export only for impure rules.forms/src/Forms/Controls/UploadControl.php
Line 36 in 1592cf6
The text was updated successfully, but these errors were encountered: