-
Notifications
You must be signed in to change notification settings - Fork 7.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add function support for form rules validation #5679
base: main
Are you sure you want to change the base?
Conversation
|
WalkthroughThis pull request enhances the dynamic handling of form validation rules across several form components. The modifications add checks to determine if rule definitions are functions, allowing for flexible evaluation of required fields, default values, and initialization logic. In addition, the type definitions have been extended to support function-based (and potentially asynchronous) validations. These changes adjust computed properties and initialization routines without altering any exported or public API declarations. Changes
Sequence Diagram(s)sequenceDiagram
participant Form as Form Component
participant Logic as Computed/Init Logic
participant Util as isFunction Checker
participant Rule as Rule Definition
Form->>Logic: Trigger evaluation (e.g., required, shapes, initial values)
Logic->>Util: Check if rule is a function
Util-->>Logic: Return boolean result
alt Rule is a function
Logic->>Form: Apply dynamic rule logic (set required=true, default=undefined, etc.)
else Rule is not a function
Logic->>Form: Process rule using existing static conditions
end
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (4)
⏰ Context from checks skipped due to timeout of 90000ms (2)
🔇 Additional comments (6)
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Description
在表单的
schema.rules
中添加对函数的支持,可以直接使用异步函数对表单进行校验。Type of change
Please delete options that are not relevant.
pnpm-lock.yaml
unless you introduce a new test example.Checklist
pnpm run docs:dev
command.pnpm test
.feat:
,fix:
,perf:
,docs:
, orchore:
.Summary by CodeRabbit
New Features
Refactor