Skip to content

feature: add Minimum Length option for text fields - #7605

Open
faisalahammad wants to merge 3 commits into
pods-framework:release/3.4.0from
faisalahammad:feature/7413-minimum-length
Open

feature: add Minimum Length option for text fields#7605
faisalahammad wants to merge 3 commits into
pods-framework:release/3.4.0from
faisalahammad:feature/7413-minimum-length

Conversation

@faisalahammad

Copy link
Copy Markdown
Contributor

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

  1. Edit (or add) a Plain Text, Plain Paragraph Text, or WYSIWYG field.
  2. Open its options and set Minimum Length to a number (for example 10). Save the field.
  3. Edit an item and enter a value shorter than the minimum, then save.
  4. See the save blocked with the message " must be at least N characters long."
  5. Enter a value at or above the minimum and save again.
  6. Confirm it saves successfully, and that leaving the field empty saves normally.

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

- 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
faisalahammad changed the base branch from main to release/3.4.0 August 18, 2026 10:50
@faisalahammad

Copy link
Copy Markdown
Contributor Author

AI disclosure: this PR was written with Claude Opus 5 assistance, reviewed and tested by me.

faisalahammad and others added 2 commits August 19, 2026 23:44
… 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a "Minimum Length" Option for Text Fields (Quick Win!)

1 participant