问题
I want to validate object that keys should be in asending order e.g.
// valid because all keys are in order
var object = {
0: 'alok',
1: 'singh',
2: 'mahor'
}
// not valid because all keys are not in order
var object = {
2: 'alok',
0: 'singh',
1: 'mahor'
}
// not valid because all keys are not in order
var object = {
1: 'alok',
2: 'singh',
0: 'mahor'
}
// this is not capable of checking key order
var schema = Joi.object({
0: Joi.string(),
1: Joi.string(),
2: Joi.string()
});
how can I validate order of keys using Joi?
来源:https://stackoverflow.com/questions/58933028/how-to-validate-key-order-in-javascript-object-using-joi