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
Nested Validations Resolved #88
Conversation
👍 |
2 similar comments
👍 |
👍 |
🐑 |
🍻 |
@jac33k can you please rebase? |
@joneslee85 done, I've noticed slight decrease of coverage, because of one (not used) method for |
@@ -442,6 +442,30 @@ error.name # => "address.street" | |||
error.attribute_name # => "street" | |||
``` | |||
|
|||
Also you can use validations nested in Hanami Validations object. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would avoid using subject 'you' here if possible
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any particular reason? Just curious ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Validations can be nested in Hanami::Validations objects
^
statement
Also you can use validations nested in Hanami Validations object
^
action
Fixed by #100 |
Hey there!
I've tried Lotus for one of my backend services (suits perfect, btw) and I faced the problem with nested objects' validation.
I want to keep the information about the object (like validations) in separate classes (so DSL for nesting objects was not satisfying for me). Let me show you an example:
Even if the coercion works fine for this example, there's no info about nested object validation, so I had to hack it this way:
Looks ugly, huh? (and changing the framework's default behaviour (in most cases) tells you that you shouldn't have been using framework at all)
I've resolved it in my fork (more details and examples in tests and ReadMe) and now sending the PR for review. Let me know if that might be helpful for any of Lotus' users.
P.S. This PR includes nested coercion and validations for
Array[YourClass]
- it was useful for me the way it is, maybe should inside a collection wrapper (didn't need that).