@iap Packages
    Preparing search index...

    Function validateForm

    • 对表单数据对象按 Schema 进行整体校验 返回 { valid, errors },其中 errors 为字段名到错误信息的映射

      Parameters

      • values: Record<string, unknown>

        表单数据对象,key 为字段名

      • schema: ValidationSchema

        校验规则 Schema,key 为字段名

      Returns { errors: ValidationErrors; valid: boolean }

      { valid: boolean; errors: ValidationErrors } — valid 为 true 时 errors 为空对象

      const { valid, errors } = validateForm(
      { email: '', password: 'abc' },
      {
      email: { required: true },
      password: { required: true, minLength: 8 },
      }
      )