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

Make a function that throws validation errors based on a check pattern #3

Open
stubailo opened this issue Nov 23, 2015 · 3 comments
Open

Comments

@stubailo
Copy link
Contributor

Mostly for transition purposes for people who are familiar with check.

Hard requirement - it still needs to throw ValidationError errors, but I think this is achievable by using simple-schema under the hood.

@stubailo stubailo changed the title Add an option to validate arguments with check instead of SimpleSchema Make a function that throws validation errors based on a check pattern Dec 1, 2015
@stubailo
Copy link
Contributor Author

stubailo commented Dec 1, 2015

@aldeed is this easy to do with SimpleSchema? Can I somehow easily convert a check pattern into a SimpleSchema instance, and then get a validator function out of it?

@aldeed
Copy link
Contributor

aldeed commented Dec 2, 2015

SS does not use match patterns internally and I'm not aware of anyone having written a converter.

The simple option is a wrapper function that just catches the check error, smooshes it into a ValidationError, and rethrows it. This would not have field-specific errors I think.

Otherwise a pkg that converts match patterns to SS syntax could be useful, similar to https://atmospherejs.com/bshamblen/json-simple-schema (validate: (new MatchPattern({})).toSimpleSchema().validator())

@stubailo
Copy link
Contributor Author

stubailo commented Dec 2, 2015

Hmm, yeah. I am also probably OK with people not getting the fancy validator functionality if they use check in the meanwhile.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants