-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
DataForm: move validation logic to the field type definition #64164
Conversation
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
return { | ||
sort: () => 0, | ||
isValid: ( value: any, elements?: Option[] ) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering about the elements
argument here. I'm not sure it makes sense for all types and some types might have their own specific config (min, max for integer for instance...), so how can we make this more generic and that works for all types.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can pass the field as an argument instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, agree. I made a mental note about this but forgot to implement it, this is what I had in mind d13edc0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure I like the "context" name but I think it's is good for now.
Part of #59745
Follow-up to #64064
What?
This PR is a refactor, it doesn't modify any behavior. It moves the DataForm's validation logic into the corresponding field type definition.
Why?
With the introduction of field type definitions at #64064 we are now able to centralize more parts of the logic there.
How?
Extracts logic from
validation.ts
into the corresponding field type definition.Testing Instructions
Verify the order modal still works as before:
Gravacao.do.ecra.2024-08-01.as.11.03.06.mov