Repository navigation
fix(validator): unblock names with no built-in implementation - #396
Merged
Merged
Conversation
v1.15.0 (#162) reserved 13 validator names, but the Elements validate directive only implements required, email, url, min and max. Names like minlength, maxlength, pattern, match, number, integer, alpha and alphanumeric had no built-in to protect, so blocking them removed a capability that worked from v1.0.2 to v1.14.1. - Reserve only the five names Elements implements; same warning - Fix comment that claimed core validators come from Elements - Document the reserved names in forms-validation docs and llms*.txt - Rebuild dist (compiler.mjs also picks up config changes already on main)
ErickXavier
added a commit
that referenced
this pull request
Oct 15, 2026
Reapply of #396 (13bac8b) on the 1.22 line. v1.15.0 (#162) reserved 13 validator names, but the Elements validate directive only implements required, email, url, min and max. Names like minlength, maxlength, pattern, match, number, integer, alpha and alphanumeric had no built-in to protect, so blocking them removed a capability that worked from v1.0.2 to v1.14.1. - Reserve only the five names Elements implements; same warning - Document the reserved names in forms-validation docs and llms*.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
From v1.0.2 to v1.14.1,
NoJS.validator(name, fn)accepted any name. In v1.15.0, #162 (63123ad) added_BUILTIN_VALIDATOR_NAMESand refused 13 names with a "built-in validator, cannot be overridden" warning.NoJS-Elements
src/validate/element.js(origin/main) only implementsrequired,email,url,min,max(plus thecustom:<name>dispatcher). The other 8 reserved names (minlength,maxlength,pattern,match,number,integer,alpha,alphanumeric) have no built-in. Blocking them protected nothing and removed a capability users had. A user-registeredminlengthworked on v1.14.1 and silently stopped working on v1.15.0+.Changes
src/index.js:_BUILTIN_VALIDATOR_NAMESis nowrequired,email,url,min,max. The refusal warning is unchanged. The comment that said core validators are registered by nojs-elements was wrong and is replaced.__tests__/plugin-system.test.js: the 8 unblocked names register, run and reach plugins viaNoJS.internals.validators. The 5 implemented names are still refused with the same warning. Re-registration and argument validation are covered.docs/md/forms-validation.mdanddocs/llms-full.txtget a "Reserved names" section.docs/llms.txtreplaces the stale 13-name list.dist/: rebuilt.dist/compiler/compiler.mjsalso picks up_configchanges that were already on main but had not been rebuilt (templates.pageRelative, i18nescapeParams/strictLocale, thestrict*flags).customstays registrable, as on v1.21.1. It was never in the blocklist, and blocking it now would break code that works today.Verification
Browser probe (Chromium, port 3949). Each validator is registered before Elements loads, and each field is filled and blurred. Results:
Integration check:
validate="minlength:3"with a user-registeredminlengthgives the user's error on this build plus Elements origin/main (built from source).npx jest: 60 suites, 2815/2815 passnpm run lint: cleanThe v1.21.1
__tests__run against this branch'ssrc/: 2287/2287 passscripts/compat-check.sh --working-tree --port 3949: e2e 114 passed (Chromium, Firefox, WebKit), unit 37/37 passNote
Elements snapshots the validator registry when it installs (
NoJS.internals.validatorsis a frozen copy). Validators registered after the Elements script loads are ignored. This was already true on v1.14.1. The new docs tell users to register validators before Elements loads.