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

Shouldn't the before() callback modify the value that is actually going to be validated? #179

Open
diegovilar opened this issue Apr 8, 2017 · 0 comments

Comments

@diegovilar
Copy link

If you define a before(value) => newValue callback for a property, the transformed input is not the one that is going to be validated. The validation will occur against the original input.

Shouldn't the validation function be passed the transformed input instead?

My use case is that I'm asking for a version string, which will ultimately be validated against a Semantic Version pattern, but I want to be flexible enough to allow the user to input simple versions (i.e. 1 or 1.1). My before() transformation function handles such cases (and only such cases) and transforms the input into valid semver values (i.e. 1.0.0 and 1.1.0). Any other value is returned as-is by the transformation function to be validated against pattern. #

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