Add NoSuspiciousCharacters constraint (spoofing checks)#95
Merged
strider2038 merged 6 commits intoApr 6, 2026
Merged
Conversation
Implement it.NoSuspiciousCharacters with Symfony-aligned check flags, optional locale and single-script restrictions, validate/is helpers, messages and translations, tests and examples. Behavior approximates Symfony ICU Spoofchecker without CGO; document differences in godoc. Co-authored-by: Igor Lazarev <strider2038@yandex.ru>
Resolve CHANGELOG [Unreleased] by keeping both IBAN (main) and NoSuspiciousCharacters entries. Co-authored-by: Igor Lazarev <strider2038@yandex.ru>
Use declarative Has* naming for package it; document convention in validation-add-constraint skill. Add CHANGELOG [Changed] note. Co-authored-by: Igor Lazarev <strider2038@yandex.ru>
Feature is unreleased on this branch; public API is HasNoSuspiciousCharacters from the start—no rename to document under [Unreleased]. Co-authored-by: Igor Lazarev <strider2038@yandex.ru>
…d tests Remove is.NoSuspiciousCharacters. Replace it.WithChecks with bitmask methods CheckInvisible/MixedNumbers/HiddenOverlay and Without* defaults. Extend validate tests for masks, locales edge cases, helpers, and Zl/Zp/Cf. Update changelog and validation-add-constraint skill. Co-authored-by: Igor Lazarev <strider2038@yandex.ru>
- needsScriptCheck: include Unicode Nd for locale restriction - iso15924ToUnicodeScripts: Hira/Kana/Hang/Bopo aliases - Tests: ja-Hira + hiragana, en + Arabic-Indic digits, Hira/Kana tables - CHANGELOG [Unreleased] Fixed Co-authored-by: Igor Lazarev <strider2038@yandex.ru>
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
Adds a NoSuspiciousCharacters constraint inspired by Symfony’s
NoSuspiciousCharacters(ICU Spoofchecker), implemented without CGO usingunicode/unicode/utf8andgolang.org/x/text/languagefor locale script hints.API
it.HasNoSuspiciousCharacters()(declarativeHas*naming) with options:WithChecks,WithSuspiciousRestriction,WithSuspiciousLocales, per-violation message/error overrides,When/WhenGroups. Constraint type:HasNoSuspiciousCharactersConstraint.validate.NoSuspiciousCharacterswithvalidate.WithSuspiciousChecks,WithSuspiciousRestriction,WithSuspiciousLocales.is.NoSuspiciousCharactersboolean helper.ErrSuspiciousInvisible,ErrSuspiciousMixedNumbers,ErrSuspiciousHiddenOverlay,ErrSuspiciousCharactersRestrictionwith English defaults and Russian translations (Symfony-aligned wording where applicable).Behavior notes
Nd); Latin i/j/l + U+0307 as hidden overlay.language.Tag.Script()tounicode.Scripts(with a small ISO15924→script-name map for composite scripts like Jpan/Kore); Latin is always allowed alongside locale scripts for realistic identifiers.Semantics may differ from ICU on edge cases; this is documented in godoc.
Merge
Branch merged latest
origin/main(includes IBAN); changelog conflict resolved by listing both IBAN and NoSuspiciousCharacters under[Unreleased]→Added.Changelog
[Unreleased]→Changed:itconstructor renamed fromNoSuspiciousCharacterstoHasNoSuspiciousCharactersfor declarative naming.Testing
go test -race ./...golangci-lint run(v2.11.4)Closes Linear IGO-43 when merged (optional follow-up: align further with Symfony restriction levels).