📅  最后修改于: 2022-03-11 15:02:47.283000             🧑  作者: Mango
const Joi = require('Joi');
const schema = Joi.object({
username: Joi.string()
.min(2)
.max(30)
.required()
.pattern(new RegExp(/^(?!.*\.\.)(?!.*\.$)[^\W][\w.]{0,29}$/))
.message({"string.pattern.base":"Invalid username",
"string.min":"minimum 2 character required",
"string.max":"maximum 30 characters allowed"})
});
//
messages: {
'any.custom': [Object],
'any.default': [Object],
'any.failover': [Object],
'any.invalid': [Object],
'any.only': [Object],
'any.ref': [Object],
'any.required': [Object],
'any.unknown': [Object],
'string.alphanum': [Object],
'string.base': [Object],
'string.base64': [Object],
'string.creditCard': [Object],
'string.dataUri': [Object],
'string.domain': [Object],
'string.email': [Object],
'string.empty': [Object],
'string.guid': [Object],
'string.hex': [Object],
'string.hexAlign': [Object],
'string.hostname': [Object],
'string.ip': [Object],
'string.ipVersion': [Object],
'string.isoDate': [Object],
'string.isoDuration': [Object],
'string.length': [Object],
'string.lowercase': [Object],
'string.max': [Object],
'string.min': [Object],
'string.normalize': [Object],
'string.token': [Object],
'string.pattern.base': [Object],
'string.pattern.name': [Object],
'string.pattern.invert.base': [Object],
'string.pattern.invert.name': [Object],
'string.trim': [Object],
'string.uri': [Object],
'string.uriCustomScheme': [Object],
'string.uriRelativeOnly': [Object],
'string.uppercase': [Object]
}
//$uj@y