Open raderio opened 5 years ago
Good idea. I would be open for a pull request for this.
I am not quite sure yet how the DSL should look like. One possibility I could think of would look like this
Person::email {
inOrder {
pattern("\\w+@bigcorp.com") hint "Organizers must have a BigCorp email address"
uniqueInDatabase(dao) hint "Email has been taken"
}
}
@nlochschmidt I wonder if default behaviour should be changed to seqential (eg. fail fast) and accumulate
modificator added to support getting all errors from validator.
I would not recommend anyone doing this and keep things like network calls and database lookups separate from the unitial validation, but it would be possible by adding free-form validations and context-dependent validation, so would be fixed by having both #65 and #98
For example I want to validate an email field, I want to validate it against a regexp pattern, and only it is a valid email I want to check if it is already taken(persisted in database).