-
Notifications
You must be signed in to change notification settings - Fork 2.8k
TextBox: Data-type validation for max chars (fixes #18817) #20843
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
base: main
Are you sure you want to change the base?
Conversation
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.
Pull Request Overview
This PR adds input validation constraints to the TextBox property editor's "Maximum allowed characters" configuration field. The change prevents developers from entering invalid values (outside the 1-512 range) through the UI, addressing issue #18817.
Key Changes
- Added
configarray to themaxCharssetting with min (1), max (512), and placeholder (512) constraints - Removed the description text that previously indicated "If empty, 512 character limit"
src/Umbraco.Web.UI.Client/src/packages/property-editors/text-box/Umbraco.TextBox.ts
Show resolved
Hide resolved
src/Umbraco.Web.UI.Client/src/packages/property-editors/text-box/Umbraco.TextBox.ts
Show resolved
Hide resolved
AndyButland
left a comment
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.
Can verify this corrects the issue on the client, and I've added an equivalent server-side validation to to protect against direct requests to the management API.
Can be verified by a request using the Swagger UI and manipulating the provided maxChars value , e.g. for an existing textbox date type to:
PUT /umbraco/management/api/v1/data-type/{id}
{
"name":"Test Box (50 Chars)",
"editorAlias":"Umbraco.TextBox",
"editorUiAlias":"Umb.PropertyEditorUi.TextBox",
"values":[
{
"alias":"maxChars",
"value":50
},
{
"alias":"inputType",
"value":"text"
}
]
}
src/Umbraco.Web.UI.Client/src/packages/property-editors/text-box/Umbraco.TextBox.ts
Show resolved
Hide resolved
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.
Pull Request Overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
Fixes #18817
With the aspect that this guides the deveoper to do it right via the UI.