Closed hackerart closed 6 years ago
This project follows the same rules as Mongoose (check out their docs).
In that case, it will be:
{
phoneNumber: {
type: String,
match: /\(?([0-9]{3})\)?([ .-]?)([0-9]{3})\2([0-9]{4})/,
},
productType: {
type: String,
enum: ['bread', 'milk']
}
}
validate
accepts a function. You can use it to create custom validations.
I want to create validation for phoneNumber
phoneNumber:{ type: String, validate: /\(?([0-9]{3})\)?([ .-]?)([0-9]{3})\2([0-9]{4})/ }
or to choose validate that value equals only one of providedproductType: { type: String, validate: ['bread', 'milk'] }