Skip to content

fix(validator): unblock names with no built-in implementation - #396

Merged
ErickXavier merged 1 commit into
mainfrom
fix/validator-unblock-unimplemented-names
Oct 14, 2026
Merged

ErickXavier merged 1 commit into
mainfrom
fix/validator-unblock-unimplemented-names

Conversation

@ErickXavier

Copy link
Copy Markdown
Collaborator

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_NAMES and refused 13 names with a "built-in validator, cannot be overridden" warning.

NoJS-Elements src/validate/element.js (origin/main) only implements required, email, url, min, max (plus the custom:<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-registered minlength worked on v1.14.1 and silently stopped working on v1.15.0+.

Changes

  • src/index.js: _BUILTIN_VALIDATOR_NAMES is now required, 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 via NoJS.internals.validators. The 5 implemented names are still refused with the same warning. Re-registration and argument validation are covered.
  • Docs: docs/md/forms-validation.md and docs/llms-full.txt get a "Reserved names" section. docs/llms.txt replaces the stale 13-name list.
  • dist/: rebuilt. dist/compiler/compiler.mjs also picks up _config changes that were already on main but had not been rebuilt (templates.pageRelative, i18n escapeParams/strictLocale, the strict* flags).

custom stays 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:

    Build 8 unblocked names required/email/url/min/max custom
    core v1.14.1 + Elements v1.14.1 user fn runs user fn runs (override) user fn runs
    core v1.21.1 + Elements v1.21.1 refused, no error refused, built-in runs user fn runs
    this PR + Elements origin/main user fn runs (= v1.14.1) refused, built-in runs (= v1.21.1) user fn runs

    Integration check: validate="minlength:3" with a user-registered minlength gives the user's error on this build plus Elements origin/main (built from source).

  • npx jest: 60 suites, 2815/2815 pass

  • npm run lint: clean

  • The v1.21.1 __tests__ run against this branch's src/: 2287/2287 pass

  • scripts/compat-check.sh --working-tree --port 3949: e2e 114 passed (Chromium, Firefox, WebKit), unit 37/37 pass

Note

Elements snapshots the validator registry when it installs (NoJS.internals.validators is 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.

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
ErickXavier merged commit 8782703 into main Oct 14, 2026
1 check passed
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant