-
-
Notifications
You must be signed in to change notification settings - Fork 106
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
"NoMethodError" error raised when validating nil value with maybe(:array)
#390
Comments
I think it's just |
Alternatively: schema = Dry::Schema.JSON do
required(:list).maybe(:array) do
nil? | each(:string)
end
end |
Thanks for the fast response! These options work for me. Do you mind if I update the doc to include them so that people are less confused when using |
@hieuk09 sure, feel free! |
There is inconsistent behaviour now, because on dry-validation it is possible to use a Maybe this should be fixed instead of documenting a caveat. |
I don't think it's a bug in the first place. OTOH, it's safe to be changed, it seems. |
Describe the bug
When using
maybe(:array)
, if the value isnil
, error is raised instead of returning success object.To Reproduce
Expected behavior
It should be consistent with
maybe
behavior for other types and return a result object, something like:#<Dry::Schema::Result{:list=>nil} errors={} path=[]>
My environment
The text was updated successfully, but these errors were encountered: