react-component / react-component/field-form

表单rule增加一个groupId选项

Open
#588 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
1k
Forks
286
Avg merge
4d 16h
Merged PRs (30d)
1

Description

业务场景

有两个按钮分别是【暂存】【提交】,点击【暂存】时要求只校验部分规则(如:字符长度,选择数量,不做必填校验)点击【提交】时全部规则校验。

一般实现这个功能可能要借助一个flag去判断,这使得业务代码看着挺乱的。

现在希望添加Rule 增加 groupId 字段用于给规则分组,添加validateFieldsByGroupIds(['groupId1', 'groupId2'])去校验对应的规则

或者改造增强validateFields方法,给一个predicate去断言

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the existing Rule definition and validateFields API, then trace how field rules are selected during validation. Compare the proposed groupId-based validateFieldsByGroupIds API with the predicate alternative; the work is done when one clear approach supports partial validation for save versus full validation for submit and has tests covering both cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
frontend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.