This is an automated email from the ASF dual-hosted git repository.

lukaszlenart pushed a commit to branch docs/html5-constraint-validation
in repository https://gitbox.apache.org/repos/asf/struts-site.git

commit acbface9d4c8e99b72998fadc8b1d5fdb9d197ed
Author: Lukasz Lenart <[email protected]>
AuthorDate: Tue Aug 25 00:27:39 2026 +0200

    docs: fix the stringlength example's direction (server accepts, browser 
blocks)
    
    The previous sentence said a stringlength validator with maxLength="4" would
    reject "abcd " server-side after trimming — backwards. Trimmed to "abcd" (4
    chars), StringLengthFieldValidator.validateValue only rejects when
    trimmedLength > maxLengthToUse, and 4 > 4 is false, so the server accepts 
it.
    The paragraph exists to show the server-accepts/browser-blocks asymmetry 
that
    makes emitting the constraint attribute risky if trim isn't false; an 
example
    asserting the opposite direction illustrated nothing.
    
    Corrected to state the server accepts "abcd " while a browser maxlength="4"
    would stop the fifth character from ever being typed, matching the direction
    of the retained [a-z]+/"abc " regex example alongside it.
    
    Co-Authored-By: Claude Opus 5 <[email protected]>
---
 source/core-developers/client-side-validation.md | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/source/core-developers/client-side-validation.md 
b/source/core-developers/client-side-validation.md
index d81b9c3ea..1bf76e2b4 100644
--- a/source/core-developers/client-side-validation.md
+++ b/source/core-developers/client-side-validation.md
@@ -93,9 +93,10 @@ for the `required` validator on those two types alone.
 **Both `minlength`/`maxlength` and `pattern` need `trim="false"`, which is not 
the default.** Both
 `StringLengthFieldValidator.trim` and `RegexFieldValidator.trim` default to 
`true`, so the server measures
 or matches the field's *trimmed* value while the HTML attribute constrains the 
*raw* one. A `stringlength`
-validator with `maxLength="4"` would reject `"abcd "` server-side after 
trimming while the browser, seeing
-five raw characters, would block it first — and a `regex` of `[a-z]+` would 
accept `"abc "` server-side
-while the browser blocks it. Because of this, `minlength`/`maxlength` and 
`pattern` are only ever emitted
+validator with `maxLength="4"` accepts `"abcd "` — it trims to four 
characters, which is within the limit —
+but a browser enforcing `maxlength="4"` would stop the user typing the fifth 
character at all. Likewise, a
+`regex` of `[a-z]+` accepts `"abc "` server-side (it trims to `"abc"` first) 
while the browser, matching the
+raw value, blocks it. Because of this, `minlength`/`maxlength` and `pattern` 
are only ever emitted
 for validators explicitly configured with `trim="false"` — which most existing 
`stringlength` and `regex`
 validators are not. In practice, expect both to show up rarely until 
applications start setting
 `trim="false"` deliberately for fields where it's safe.

Reply via email to