-
-
Notifications
You must be signed in to change notification settings - Fork 1
Async validation
Alan Berdinelli edited this page Apr 18, 2021
·
4 revisions
You can use the static validate method which is async:
// From v1.4.2 you can pass an object directly to validate method:
const someSchema = {
name: {
type: String
}
};
const someSchemy = new Schemy({
name: {
type: String
}
});
async function doStuff() {
await Schemy.validate({name: 'Schemy'}, someSchema); // => { name: 'Schemy' }
}Of course, schemy supports promise too:
function doStuff() {
Schemy
.validate(input, someSchema)
.then(validatedBody => {
console.log(validatedBody.name);
})
.catch(err => {})
}Developed with ♥ by Alan Berdinelli.