Validation插件的中间件适配器 允许将validation插件作为中间件使用,兼容原validator中间件的接口 支持字段验证、类型检查、格式验证等功能
验证规则对象,键为字段名,值为验证规则
中间件函数
router.use(validator({ username: { type: 'string', required: true, minLength: 3, maxLength: 20 }, age: { type: 'number', required: true, min: 18, max: 120 }})) Copy
router.use(validator({ username: { type: 'string', required: true, minLength: 3, maxLength: 20 }, age: { type: 'number', required: true, min: 18, max: 120 }}))
Validation插件的中间件适配器 允许将validation插件作为中间件使用,兼容原validator中间件的接口 支持字段验证、类型检查、格式验证等功能