Form-Level Validation Rule
还没有人认领这个 Issue。
评估
调研方向
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 内容生成。
描述
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
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
VeryGoodOpenSource/formz 的其他 Issue
-
feature
难度 4/5 3-5 天 新手友好度 52/100
VeryGoodOpenSource/formz#166 ·
-
Clear a TextField without a TextEditingController.可能重新可做 @eraps7 于 964 天前认领,目前没有进行中的 PR。 未关闭
难度 5/5 一周以上 新手友好度 25/100
VeryGoodOpenSource/formz#111 · 1 条评论 · 1 个 reaction ·
-
documentation p3
难度 4/5 3-5 天 新手友好度 35/100
VeryGoodOpenSource/formz#110 · 1 条评论 · 8 个 reaction ·
-
documentation p3
难度 4/5 3-5 天 新手友好度 25/100
VeryGoodOpenSource/formz#101 · 2 个 reaction ·
-
难度 3/5 1-2 天 新手友好度 42/100
VeryGoodOpenSource/formz#86 · 2 条评论 ·
查看 VeryGoodOpenSource/formz 的全部 Issue
相似的 Issue
-
area: ui feature priority: medium
难度 1/5 1 小时以内 新手友好度 90/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 63/100
AimesSoft/NipaPlay-Reload#1022 ·
维护者通常 1 天内回复
-
`jwtPayload.roomConfiguration` returns null fields for tokens from LiveKit server SDKs可能已有人在做 @RaphaelFakhri 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
livekit/client-sdk-flutter#1243 ·
维护者通常 1 天内回复
-
bug to check
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 65/100
zjs81/meshcore-open#602 · 3 条评论 ·
维护者通常 1 天内回复