对表单数据对象按 Schema 进行整体校验 返回 { valid, errors },其中 errors 为字段名到错误信息的映射
{ valid, errors }
errors
表单数据对象,key 为字段名
校验规则 Schema,key 为字段名
{ valid: boolean; errors: ValidationErrors } — valid 为 true 时 errors 为空对象
{ valid: boolean; errors: ValidationErrors }
const { valid, errors } = validateForm( { email: '', password: 'abc' }, { email: { required: true }, password: { required: true, minLength: 8 }, }) Copy
const { valid, errors } = validateForm( { email: '', password: 'abc' }, { email: { required: true }, password: { required: true, minLength: 8 }, })
对表单数据对象按 Schema 进行整体校验 返回
{ valid, errors },其中errors为字段名到错误信息的映射