feat: add locale and geo string format rules - #256
Merged
Conversation
|
Test coverage changes:
|
# Conflicts: # internal/messagetemplates/templatekey_string.go
# Conflicts: # go.mod # go.sum # go.work.sum
Collaborator
There was a problem hiding this comment.
⚠️ 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.
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.
Motivation
pkg/ruleswas 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, andrules.StringLongitude.