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

Check is string #27

Open
tonyxiao opened this issue Oct 13, 2016 · 3 comments
Open

Check is string #27

tonyxiao opened this issue Oct 13, 2016 · 3 comments

Comments

@tonyxiao
Copy link

how do you check a body parameter is actually string, rather than number or null or object?

@mikiebrenbren
Copy link

use the 'typeof' operator, if it is not a string you can push an error on to the errors array (create one if it does not exist) which is on the context.

should look similar to this
if (typeof someValue !== 'string'){ context.errors = context.errors || [] context.errors.push({notString:Field must be a string!}) }

@tonyxiao
Copy link
Author

I see. I would have expected / hoped for something built in for this. But ok :)

@manuel-di-iorio
Copy link

+1 for isString() validator

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

3 participants