feature: add Minimum Length option for text fields - #7605
Open
faisalahammad wants to merge 3 commits into
Open
Conversation
- Add text, paragraph, wysiwyg min_length field options (default 0 = no minimum) - Reject non-empty values shorter than the minimum on save with a clear error - Enforce server-side only; leaves blank values to the existing required check Gives authors a way to require a certain amount of text in a field, matching the existing Maximum Length option. Min length cannot be enforced by truncation like max length, so it validates instead and blocks the save. Fixes pods-framework#7413
faisalahammad
requested review from
JoryHogeveen and
sc0ttkclark
as code owners
August 14, 2026 22:50
Contributor
Author
|
AI disclosure: this PR was written with Claude Opus 5 assistance, reviewed and tested by me. |
… errors .phpcs.xml enables WordPress.WP.I18n, which requires a translators comment on any sprintf( __( ... ) ) carrying placeholders. Every other translated error string in classes/fields/ has one (phone.php:177, website.php:233, email.php:150, link.php:245, pick.php:1408), so these three would have failed phpcs. Placeholders are numbered at the same time so translators can reorder the label and the count, which several languages need. Refs pods-framework#7413
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds a Minimum Length option to the Plain Text, Plain Paragraph Text, and WYSIWYG field types. It mirrors the existing Maximum Length option, but enforces a floor instead of a ceiling: a non-empty value shorter than the configured minimum is rejected on save with a clear error.
Maximum Length works by silently truncating the value, which is not possible for a minimum. So instead the new option validates in each field's
validate()method and blocks the save when the cleaned value is shorter than the minimum. Blank values are left to the existing required-field check, so a minimum is never enforced on an empty field.Related GitHub issue(s)
Fixes #7413
Testing instructions
10). Save the field.Screenshots / screencast
None. This is an admin option plus server-side validation, with no visible front-end change beyond the existing error messaging.
Changelog text for these changes
Enhancement: Text, Paragraph, and WYSIWYG fields now support a Minimum Length option that requires non-empty values to meet a character floor on save. #7413 (@faisalahammad)
PR checklist