Add IANA timezone validation constraint (IGO-35)#104
Draft
strider2038 wants to merge 1 commit into
Draft
Conversation
Implement it.IsTimezone with optional WithZone regional filter, validate.Timezone, and is.Timezone aligned with Symfony Timezone. Uses time.LoadLocation and rejects non-IANA names like Local and EST. 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 IANA timezone validation aligned with Symfony
Timezone:it.IsTimezone()with optionalWithZone()regional filtervalidate.Timezone()withWithTimezoneZone()andTimezoneZone*constantsis.Timezone()boolean helpervalidation.ErrInvalidTimezonewith English and Russian translationsValidation uses
time.LoadLocationand accepts canonical IANA identifiers (UTCorRegion/City). Implementation-specific names (Local,Factory) and bare abbreviations (EST,GMT) are rejected.Also closes IGO-33 (Currency) in Linear — already implemented in the codebase.
Test plan
go test -race ./...golangci-lint runtest/constraints_date_time_test.govalidate/timezone_test.goit/example_test.go,validate/example_test.go,is/example_test.go