Skip to content
This repository was archived by the owner on Mar 16, 2026. It is now read-only.

Fix: TextType - Over-length value validates when both max and min spe…#4537

Open
gsteinert wants to merge 1 commit intokeystonejs:masterfrom
gsteinert:text-input-min-max
Open

Fix: TextType - Over-length value validates when both max and min spe…#4537
gsteinert wants to merge 1 commit intokeystonejs:masterfrom
gsteinert:text-input-min-max

Conversation

@gsteinert
Copy link
Copy Markdown

…cified #4536

Description of changes

Change validation logic for TextType to ensure an overlength string is invalidated when both max and min are specified.
Tests to support

Related issues (if any)

#4536

Testing

  • Please confirm npm run test-all ran successfully.
    No new failures. 7 failed tests in unrelated areas, all pre-existing.

@autoboxer
Copy link
Copy Markdown
Contributor

looks good @gsteinert, but I think there might be one more needed change. When result is initialized, there's a check on the passed in value:

var result = value === undefined || value === null || typeof value === 'string';

It seems like the check you added needs to be mirrored in the max check as well to not lose that validation:

if (result && max && typeof value === 'string') {
    result = value.length < max;
}

What happens in you branch if a value is given that fails the first check (isn't undefined, null, or a string)?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants