validate()
const schema = new Schema({ firstname: { type: String }, lastname: { type: String } });
const User = gstore.model('User', schema);
const user = new User({ firstname: 'John', lastname: 'Snow' });
const { error } = user.validate();
// error === null --> validconst user = new User({ firstname: 'John', lastname: 'Snow' });
user.validate()
.then((value) => {
// value is the entityData sanitized
}, (err) => {
// the validation Error
});Last updated
Was this helpful?