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

Object validation throwing error #107

Open
Jason-Bellomy opened this issue Oct 6, 2015 · 1 comment
Open

Object validation throwing error #107

Jason-Bellomy opened this issue Oct 6, 2015 · 1 comment

Comments

@Jason-Bellomy
Copy link

object throws error on validation

value is an object

example of schema:
properties: {
callType: {
description: "Type of Call",
type: "object",
required: true,
properties: {
id: {
type: ["string", "number"],
required: true
},
description: {
type: 'string',
required: true
}
}
},
}

Objects are throwing errors when trying to do a validation on them. In the validateProperty there is no string check on value (in this case value is an object) and so .trim() throws an error because you can't trim an object.

@Jason-Bellomy
Copy link
Author

I have resolved a solution for this bug. All you need to add is a typeof string validation before calling the trim. Like so:

if (value === undefined || value === null || (typeof value === 'string' && value.trim() === ''))

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