Skip to content

feat: add locale and geo string format rules - #256

Merged
nieomylnieja merged 13 commits into
mainfrom
format-locale-geo
Jul 27, 2026
Merged

feat: add locale and geo string format rules#256
nieomylnieja merged 13 commits into
mainfrom
format-locale-geo

Conversation

@nieomylnieja

@nieomylnieja nieomylnieja commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

Motivation

pkg/rules was missing common locale and geographic string format validators that users otherwise had to reimplement in application code.

Summary

Added BCP 47, ISO 3166, ISO 4217, latitude, and longitude string format rules with exported error codes, message templates, validation-plan descriptions, and focused tests. The ISO 3166-2 subdivision lookup is built lazily when that rule path is used.

Testing

Added rule tests covering accepted examples, invalid messages, and error-code assertions.

Release Notes

Added rules.StringBCP47LanguageTag, rules.StringBCP47StrictLanguageTag, rules.StringISO3166Alpha2, rules.StringISO3166Alpha3, rules.StringISO3166Numeric, rules.StringISO31662, rules.StringISO4217, rules.StringLatitude, and rules.StringLongitude.

@github-actions github-actions Bot added enhancement New feature or request go Pull requests that update Go code minor New functionality with at most minor brekaing changes labels Jul 8, 2026
@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown

Test coverage changes:

Package Before After Diff
github.com/nobl9/govy/cmd/govy 0% 0% ✔️
github.com/nobl9/govy/internal 73% 73% ✔️
github.com/nobl9/govy/internal/collections 100% 100% ✔️
github.com/nobl9/govy/internal/inferpath 76% 76% ✔️
github.com/nobl9/govy/internal/messagetemplates 89% 89% ✔️
github.com/nobl9/govy/internal/stringconvert 86% 86% ✔️
github.com/nobl9/govy/internal/typeinfo 94% 94% ✔️
github.com/nobl9/govy/pkg/govy 93% 93% ✔️
github.com/nobl9/govy/pkg/govytest 100% 100% ✔️
github.com/nobl9/govy/pkg/jsonpath 85% 85% ✔️
github.com/nobl9/govy/pkg/rules 98% 99% ✔️

@nieomylnieja nieomylnieja changed the title feat: add locale and geography format rules feat: add locale and geo string format rules Jul 9, 2026

@n9-machine-user n9-machine-user left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'Govy Go Benchmark'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.50.

Benchmark suite Current: ff2d1bd Previous: a4d5d34 Ratio
BenchmarkStringBCP47LanguageTag (github.com/nobl9/govy/pkg/rules) 48500 ns/op 18016 B/op 360 allocs/op 7751 ns/op 3960 B/op 71 allocs/op 6.26
BenchmarkStringBCP47LanguageTag (github.com/nobl9/govy/pkg/rules) - ns/op 48500 ns/op 7751 ns/op 6.26
BenchmarkStringBCP47LanguageTag (github.com/nobl9/govy/pkg/rules) - B/op 18016 B/op 3960 B/op 4.55
BenchmarkStringBCP47LanguageTag (github.com/nobl9/govy/pkg/rules) - allocs/op 360 allocs/op 71 allocs/op 5.07
BenchmarkStringBCP47StrictLanguageTag (github.com/nobl9/govy/pkg/rules) 79152 ns/op 28573 B/op 582 allocs/op 13559 ns/op 6541 B/op 122 allocs/op 5.84
BenchmarkStringBCP47StrictLanguageTag (github.com/nobl9/govy/pkg/rules) - ns/op 79152 ns/op 13559 ns/op 5.84
BenchmarkStringBCP47StrictLanguageTag (github.com/nobl9/govy/pkg/rules) - B/op 28573 B/op 6541 B/op 4.37
BenchmarkStringBCP47StrictLanguageTag (github.com/nobl9/govy/pkg/rules) - allocs/op 582 allocs/op 122 allocs/op 4.77
BenchmarkStringISO3166Alpha2 (github.com/nobl9/govy/pkg/rules) 32834 ns/op 13109 B/op 266 allocs/op 16125 ns/op 7490 B/op 152 allocs/op 2.04
BenchmarkStringISO3166Alpha2 (github.com/nobl9/govy/pkg/rules) - ns/op 32834 ns/op 16125 ns/op 2.04
BenchmarkStringISO3166Alpha2 (github.com/nobl9/govy/pkg/rules) - B/op 13109 B/op 7490 B/op 1.75
BenchmarkStringISO3166Alpha2 (github.com/nobl9/govy/pkg/rules) - allocs/op 266 allocs/op 152 allocs/op 1.75
BenchmarkStringISO3166Alpha3 (github.com/nobl9/govy/pkg/rules) 34860 ns/op 14006 B/op 280 allocs/op 16838 ns/op 8002 B/op 160 allocs/op 2.07
BenchmarkStringISO3166Alpha3 (github.com/nobl9/govy/pkg/rules) - ns/op 34860 ns/op 16838 ns/op 2.07
BenchmarkStringISO3166Alpha3 (github.com/nobl9/govy/pkg/rules) - B/op 14006 B/op 8002 B/op 1.75
BenchmarkStringISO3166Alpha3 (github.com/nobl9/govy/pkg/rules) - allocs/op 280 allocs/op 160 allocs/op 1.75
BenchmarkStringISO3166Numeric (github.com/nobl9/govy/pkg/rules) 28921 ns/op 12005 B/op 240 allocs/op 14681 ns/op 7001 B/op 140 allocs/op 1.97
BenchmarkStringISO3166Numeric (github.com/nobl9/govy/pkg/rules) - ns/op 28921 ns/op 14681 ns/op 1.97
BenchmarkStringISO3166Numeric (github.com/nobl9/govy/pkg/rules) - B/op 12005 B/op 7001 B/op 1.71
BenchmarkStringISO3166Numeric (github.com/nobl9/govy/pkg/rules) - allocs/op 240 allocs/op 140 allocs/op 1.71
BenchmarkStringISO31662 (github.com/nobl9/govy/pkg/rules) 38275 ns/op 16007 B/op 320 allocs/op 18394 ns/op 8003 B/op 160 allocs/op 2.08
BenchmarkStringISO31662 (github.com/nobl9/govy/pkg/rules) - ns/op 38275 ns/op 18394 ns/op 2.08
BenchmarkStringISO31662 (github.com/nobl9/govy/pkg/rules) - B/op 16007 B/op 8003 B/op 2.00
BenchmarkStringISO31662 (github.com/nobl9/govy/pkg/rules) - allocs/op 320 allocs/op 160 allocs/op 2
BenchmarkStringISO4217 (github.com/nobl9/govy/pkg/rules) 50715 ns/op 22017 B/op 420 allocs/op 15962 ns/op 7874 B/op 160 allocs/op 3.18
BenchmarkStringISO4217 (github.com/nobl9/govy/pkg/rules) - ns/op 50715 ns/op 15962 ns/op 3.18
BenchmarkStringISO4217 (github.com/nobl9/govy/pkg/rules) - B/op 22017 B/op 7874 B/op 2.80
BenchmarkStringISO4217 (github.com/nobl9/govy/pkg/rules) - allocs/op 420 allocs/op 160 allocs/op 2.63
BenchmarkStringLatitude (github.com/nobl9/govy/pkg/rules) 31994 ns/op 13750 B/op 278 allocs/op 6861 ns/op 2953 B/op 60 allocs/op 4.66
BenchmarkStringLatitude (github.com/nobl9/govy/pkg/rules) - ns/op 31994 ns/op 6861 ns/op 4.66
BenchmarkStringLatitude (github.com/nobl9/govy/pkg/rules) - B/op 13750 B/op 2953 B/op 4.66
BenchmarkStringLatitude (github.com/nobl9/govy/pkg/rules) - allocs/op 278 allocs/op 60 allocs/op 4.63
BenchmarkStringLongitude (github.com/nobl9/govy/pkg/rules) 32367 ns/op 13750 B/op 278 allocs/op 6978 ns/op 2953 B/op 60 allocs/op 4.64
BenchmarkStringLongitude (github.com/nobl9/govy/pkg/rules) - ns/op 32367 ns/op 6978 ns/op 4.64
BenchmarkStringLongitude (github.com/nobl9/govy/pkg/rules) - B/op 13750 B/op 2953 B/op 4.66
BenchmarkStringLongitude (github.com/nobl9/govy/pkg/rules) - allocs/op 278 allocs/op 60 allocs/op 4.63

This comment was automatically generated by workflow using github-action-benchmark.

CC: @nieomylnieja

Add BCP 47, ISO 3166, ISO 4217, latitude, and longitude validators with authoritative lookup data and error metadata.
@nieomylnieja
nieomylnieja merged commit c9eda61 into main Jul 27, 2026
6 checks passed
@nieomylnieja
nieomylnieja deleted the format-locale-geo branch July 27, 2026 10:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request go Pull requests that update Go code minor New functionality with at most minor brekaing changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants