Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StopOnError is not work in static function context #706

Closed
hiscaler opened this issue May 6, 2024 · 1 comment
Closed

StopOnError is not work in static function context #706

hiscaler opened this issue May 6, 2024 · 1 comment

Comments

@hiscaler
Copy link

hiscaler commented May 6, 2024

What steps will reproduce the problem?

new StopOnError([
    new Required(),
    static function (mixed $value, Callback $rule, ValidationContext $context) {
        $id = $context->getDataSet()->getAttributeValue('product_id'); // $id is null
    }
])

can't get product_id value

What is the expected result?

Get product_id value

What do you get instead?

Remove StopOnError

@vjik
Copy link
Member

vjik commented May 17, 2024

In this case scope will be property value that validated by StopOnError. Use $context->getGlobalDataSet() to access all data.

@vjik vjik closed this as completed May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants