Package Exports
- super-ajv
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (super-ajv) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Super AJV
AJV validator with super powers! See also the AJV full documentation.
Contents
Custom Types
You can set the types you want!
const ajv = new Ajv()
ajv.addType('mongoid', {
compile: function () {
return function (data) {
const re = /^(?=[a-f\d]{24}$)(\d+[a-f]|[a-f]+\d)/i
return re.test(data)
}
}
})
const schema = {
properties: {
user_id: { type: 'mongoid' }
}
}
Required properties
You can set required property in line:
const schema = {
properties: {
user_id: { type: 'mongoid', required: true }
}
}
And can also set a required property using the '*':
const schema = {
properties: {
'*user_id': { type: 'mongoid' }
}
}
Simplifyed types
const schema = {
properties: {
'*name': 'string',
'*email': 'email',
'age': 'number',
'*message': 'string',
}
}
Test
node test/
License
"Simplicity is the ultimate sophistication"
Da Vinci