js: implement the Constraint Validation API subset this engine models - #239
Merged
Merged
Conversation
setCustomValidity/.validity/.validationMessage/checkValidity were entirely missing. This engine models no native constraints at all -- no required/pattern/min/max/step checking against a value -- so a custom validity message (dom.Node.CustomValidity, the same non-attribute runtime-field shape as round 138's Indeterminate) is the only thing that can ever make an element invalid. The ValidityState object's shape is spec-complete (all nine other flags present and always false) so a script reading any of them gets a real boolean, never undefined. checkValidity() fires a cancelable "invalid" event at the element when invalid, per spec. .willValidate is deliberately left out: zero corpus usage found for it. Found sweeping the same fresh github.com bundles round 138 came from, this time for method calls: github.com's own client-side form-validation UI (username/label/2FA-code fields) relies on this API extensively. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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
setCustomValidity/.validity/.validationMessage/checkValiditywere entirely missing.required/pattern/min/max/stepchecking against a value — so a custom validity message (dom.Node.CustomValidity, the same non-attribute runtime-field shape as round 138'sIndeterminate) is the only thing that can ever make an element invalid. TheValidityStateobject's shape is spec-complete (all nine other flags present and alwaysfalse) so a script reading any of them gets a real boolean, neverundefined.checkValidity()fires a cancelable"invalid"event at the element when invalid, per spec..willValidatedeliberately left out: zero corpus usage found for it, unlike the four members above.setCustomValidity(msg)/setCustomValidity(""), reading.validity.customError/.validationMessage, gating on.checkValidity()).Test plan
TestConstraintValidationAPI, git-stash-confirmed: reverting makes the test's own script throwTypeError: Cannot read property 'valid' of undefined.go build ./... && go vet ./... && go test ./...clean.🤖 Generated with Claude Code