We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I have a use case where the top-level object property can be anything (e.g. a UUID) with nested properties which must conform to a schema, e.g.:
const users = { abc: { name: 'Foo' }, def: { name: 'Bar' } }
Does validate support this? I've tried the following:
var Schema = require("validate") const schema = new Schema({ [/[a-z].+/]: { name: { type: String, required: true } } }) schema.validate({a: { name: 'foo' }}) //=> [ValidationError: /[a-z].+/.name is required.]
In JSON schema, this works:
{ "type": "object", "$schema": "http://json-schema.org/draft-03/schema", "required": true, "patternProperties": { "^[a-z].+$": { "type": "object", "required": true, "properties": { "name": { "type": "string", "required": true } } } } }
The text was updated successfully, but these errors were encountered:
@tlvince I'm having the same issue, have you found any solution to this?
Sorry, something went wrong.
Nope. As a workaround, I rolled my own.
@tlvince you rolled your own? A validator function or a replacement for 'validate' altogether? I have the exact same issue :/
Successfully merging a pull request may close this issue.
I have a use case where the top-level object property can be anything (e.g. a UUID) with nested properties which must conform to a schema, e.g.:
Does validate support this? I've tried the following:
In JSON schema, this works:
The text was updated successfully, but these errors were encountered: