Skip to content

Conversation

@jorgefilipecosta
Copy link
Member

Adds min/max validation support for DataForm input controls, part of #71500.

cc: @oandregal

Field Types Supported

Text-based fields (character count validation minLength/maxLength):

  • text
  • textarea
  • email
  • password
  • telephone
  • url

Numeric fields (value range validation min/max):

  • integer
  • number

Implementation

  • Updated Rules type to include minLength, maxLength, min, and max properties
  • Modified validation controls to pass these props to underlying HTML inputs using native HTML5 validation attributes
  • Added Storybook examples with a minMax toggle to demonstrate validation behavior

Testing

Enable the minMax control in the Validation Storybook story to test the validation behavior across different field types.

@github-actions
Copy link

github-actions bot commented Nov 20, 2025

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 props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: jorgefilipecosta <[email protected]>
Co-authored-by: oandregal <[email protected]>
Co-authored-by: ntsekouras <[email protected]>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@jorgefilipecosta jorgefilipecosta added [Feature] DataViews Work surrounding upgrading and evolving views in the site editor and beyond [Type] Enhancement A suggestion for improvement. labels Nov 20, 2025
@oandregal oandregal mentioned this pull request Nov 21, 2025
4 tasks
@oandregal
Copy link
Member

@jorgefilipecosta this needs to be implemented in useFormValidity as well.

@jorgefilipecosta
Copy link
Member Author

@jorgefilipecosta this needs to be implemented in useFormValidity as well.

Hi @oandregal it was fixed 👍

Comment on lines +529 to +533
( formField.field.type === 'text' ||
formField.field.type === 'email' ||
formField.field.type === 'url' ||
formField.field.type === 'telephone' ||
formField.field.type === 'password' )
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to refactor this soon so that it's the field type that runs the validation (related).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's the PR to move the validation logic to the field type #73642

@oandregal
Copy link
Member

oandregal commented Nov 27, 2025

We also need to support min and max for date and datetime field types (https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input/date#max). How do you see that working? (can be a follow-up)

@jorgefilipecosta jorgefilipecosta merged commit af6f619 into trunk Nov 27, 2025
37 checks passed
@jorgefilipecosta jorgefilipecosta deleted the add/min-max-validation branch November 27, 2025 15:44
@github-actions github-actions bot added this to the Gutenberg 22.3 milestone Nov 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Feature] DataViews Work surrounding upgrading and evolving views in the site editor and beyond [Type] Enhancement A suggestion for improvement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants