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

Add support for conditional/dependent validation #8

Open
raderio opened this issue Apr 11, 2019 · 3 comments
Open

Add support for conditional/dependent validation #8

raderio opened this issue Apr 11, 2019 · 3 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@raderio
Copy link

raderio commented Apr 11, 2019

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).

@raderio raderio changed the title Add support for conditional validation Add support for conditional/dependent validation Apr 12, 2019
@nlochschmidt nlochschmidt added the enhancement New feature or request label Apr 13, 2019
@nlochschmidt
Copy link
Member

nlochschmidt commented Apr 13, 2019

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("\\[email protected]") hint "Organizers must have a BigCorp email address"
        uniqueInDatabase(dao) hint "Email has been taken"
    }
}

@nlochschmidt nlochschmidt added the help wanted Extra attention is needed label May 3, 2022
@floatdrop
Copy link

@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.

@dhoepelman
Copy link
Collaborator

dhoepelman commented May 10, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants