Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Form-Level Validation Rule

未关闭
#121 5 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
25/100
Issue 类型
功能
描述清晰度
需要澄清
活跃度
停滞
技术栈
dart
领域
frontend

调研方向

Start by reading formz's existing individual field validators and the proposed form-level validator entry point. Determine how a rule requiring at least one of phone number, first name, or last name could coexist with individual validation and aggregate errors. Done means the package supports a documented form-level rule without leaving the validation result or submission behavior ambiguous.

由索引模型根据 Issue 内容生成。

描述

feature p3

Is your feature request related to a problem? Please describe.
Currently, the formz package excels at validating individual form fields and separating the validation logic. However, it lacks the ability to define a validation rule that applies to the entire form.

For instance, consider a use case where the user can look up a an employee by any 3 fields: phone number, first name, and last name. While formz allows validation for individual fields (e.g., ensuring phone number has 10 digits and names have at least two characters), there's no way to enforce that at least one field must be filled before submitting the search.

Describe the solution you'd like
One possible solution would involve introducing a mechanism to define form-level validation rules that can orchestrate the execution of individual field validators. In the example above, the form level validator would perform validation that least one of the three fields (phone number, first name, or last name) has a value before allowing form submission then to orchestrate the execution of individual field validators.

\\Something like
\\Form - Level validator
overide
ValidationError? validator(String value) {
  if (isAllSearchParametersEmpty(firstName: firstName, lastName: lastName, phone: phone)) {
    return AtLeastOneFieldNeededError();
  }
  //This idea
  // Directly call field validators here
  final phoneError = phone.validator();
  final firstNameError = firstName.validator();
  final lastNameError = lastName.validator();

  // Combine errors for a holistic form-level validation result
  return ... (logic to aggregate errors and return a representative error)
}
tiny code
/// ValidationError is an abstract class that is used to implement the builder pattern to create a validation error(s).
abstract class ValidationError {
  final String message;

  ValidationError(this.message);
}

I am happy create a pull request and discuss peoples thoughts on the best way to implement this

主要语言
Dart
星标
489
派生
43
PR 合并指标
30 天内没有已合并 PR

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

VeryGoodOpenSource/formz 的其他 Issue

查看 VeryGoodOpenSource/formz 的全部 Issue

相似的 Issue

更多 Dart Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。