Skip to content

Add ISO week validation with inclusive bounds - #121

Merged
strider2038 merged 1 commit into
mainfrom
feat/iso-week
Oct 2, 2026
Merged

strider2038 merged 1 commit into
mainfrom
feat/iso-week

Conversation

@strider2038

Copy link
Copy Markdown
Contributor

Adds ISO week validation for values such as 2020-W53, rejecting nonexistent weeks such as 2021-W53. it.IsWeek().WithMin("2020-W01").WithMax("2021-W01") supports inclusive ranges across ISO years; validate.Week and is.Week expose standalone validation with matching options.

  • Strict YYYY-Www format, calendar-aware week 53 validation, and separate format, week-number, minimum, and maximum violations.
  • Custom errors/messages, conditional validation, groups, generic This/Each, and English/Russian translations.
  • No new dependencies. Years 0000–9999 use Go's proleptic Gregorian calendar literally. README documents differences from Symfony: empty strings are skipped, and early years are not remapped by PHP mktime rules.
  • Malformed, nonexistent, or reversed bounds produce configuration errors. Includes examples and an Unreleased changelog entry.

Validation: bash scripts/test-all.sh (formatting, vet, golangci-lint v2.13.2, unit tests, race tests, module tidy and verification). Tests cover strict parsing, cross-year bounds, all four violations, custom messages, translations, and week 53 for every year 0000–9999 against the independent January 1/leap-year rule.

Closes #108.

@strider2038
strider2038 merged commit f026167 into main Oct 2, 2026
4 checks passed
@strider2038
strider2038 deleted the feat/iso-week branch October 2, 2026 14:28
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.

Constraint: Week (ISO week string)

1 participant