A reversed PatternValidator renders a pattern attribute that rejects the input the validator accepts
Maintainers usually reply within 1 day
@reiern70 is already working on this.
Since Nov 12, 2026.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 55/100
Research direction
The pattern attribute is written in AbstractTextComponent#onComponentTag and HTML5Attributes#onInput, both in wicket-core. Start by reading how those two places iterate over the PatternValidator instances, and add an isReverse() getter to PatternValidator. Done when a reversed validator no longer produces a pattern attribute in the rendered <input>, and the existing tests for HTML5 attributes still pass.
Written by the indexing model from the issue text.
Description
Affects: 11.0.0 and current master, on every text component. 10.x when the HTML5Attributes behavior is added.
Component: wicket-core, AbstractTextComponent, HTML5Attributes, PatternValidator
What happens
A text field with a reversed PatternValidator:
field.add(new PatternValidator("[a-z]+").setReverse(true));
renders:
<input type="text" ... pattern="[a-z]+">
The validator means "input that matches [a-z]+ is invalid". The pattern attribute tells the browser the opposite: input that does not match is invalid. A non-empty value can't pass both checks:
123is valid on the server, but the browser blocks the submit (patternMismatch, checked in Chrome and Firefox).abcpasses the browser, and the server rejects it.
Only an empty value gets through, because neither check applies to it.
Cause
AbstractTextComponent#onComponentTag (and HTML5Attributes#onInput) copies the pattern of every PatternValidator into the pattern attribute and ignores the reverse flag. PatternValidator has no getter for that flag, so the renderers can't see it.
Fix proposed
Render no pattern attribute for a reversed validator, and leave the check to the server. An HTML pattern can't express "must not match" reliably for an arbitrary Java pattern. This needs a public getter, PatternValidator#isReverse().
Workaround
Remove the attribute with a behavior added after the validator:
field.add(new Behavior() {
@Override
public void onComponentTag(Component component, ComponentTag tag) {
tag.remove("pattern");
}
});
Found while fixing #1884.
- Dominant language
- Java
- Stars
- 800
- Forks
- 437
- Avg merge
- 21h 36m
- Merged PRs (30d)
- 167
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from apache/wicket
-
PropertyResolver fails on JDK classes with a non-public field named like the propertyPossibly taken @vaibhavgupta443 claimed this today. Opengood first issue
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
apache/wicket#1991 · 1 comment ·
Maintainers usually reply within 1 day
-
Stop the autocomplete from accumulating request parameters while typingPossibly taken @aryankalantri claimed this today. Opengood first issue
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
apache/wicket#1947 · 2 comments ·
Maintainers usually reply within 1 day
-
Validate the report-uri value given to CSPHeaderConfiguration#reportBackPossibly taken @AzizOuertani claimed this 3 days ago. Opengood first issue
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
apache/wicket#1946 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 70/100
Maintainers usually reply within 1 day
Similar issues
-
account assessment course feature lecture
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
Maintainers usually reply within 1 day
-
app:learninggoalhub enhancement good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 1/5 1-3 hours Newbie friendliness 86/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100