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

String expectation with min(0) and a nullable flag does not accept null #23

Closed
finwe opened this issue Jul 16, 2020 · 1 comment
Closed

Comments

@finwe
Copy link

finwe commented Jul 16, 2020

Version: 1.0.2

Bug Description

String expectation with min(0) and a nullable flag does not accept null.

Steps To Reproduce

Expectation is defined as

$schema = Expect::structure([
    'position' => Expect::string()->min(0)->nullable(),
]);

When validating with ['position' => null], the error message raised is

"The option 'position' expects to be string or null in range 0.., null given."

Expected Behavior

The null value should be accepted according to the error message.

If failing for other reasons, null should be mentioned first in the error message for it to make more sense (only strings have "ranges")

Possible Solution

Nullable does not take precedence over string length constraint even when minimal string length is 0

@finwe
Copy link
Author

finwe commented Jul 16, 2020

Solution is to omit the ->min(0), yet the current behaviour is confusing anyway.

@dg dg closed this as completed in ab5f748 Dec 15, 2020
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

1 participant