max-validator
max-validator copied to clipboard
Document how to validate nested objects
Hi, this library looks great. Does it support validating nested objects? E.g. how could I write a schema to validate the object below?
{
name: "",
about: "",
location: {
city: "",
country: "",
lat: 0,
lng: 0
}
},
I know I can do this:
location: {
required: true,
object: true,
customRule: function (location) {
return (location.city.length > 0) ? true : "Please select a location"
}
},
But is there a way of embedding validation rules for city, country, lat, lng in the schema directly?