Skip to content

Commit

Permalink
localizable validation error
Browse files Browse the repository at this point in the history
  • Loading branch information
santhosh-tekuri committed May 4, 2024
1 parent e99697b commit f10de54
Show file tree
Hide file tree
Showing 6 changed files with 135 additions and 103 deletions.
5 changes: 3 additions & 2 deletions example_vocab_uniquekeys_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"strings"

"github.com/santhosh-tekuri/jsonschema/v6"
"golang.org/x/text/message"
)

// SchemaExt --
Expand Down Expand Up @@ -93,8 +94,8 @@ func (*UniqueKeys) KeywordPath() []string {
return []string{"uniqueKeys"}
}

func (k *UniqueKeys) String() string {
return fmt.Sprintf("items at %d and %d have same %s", k.Duplicates[0], k.Duplicates[1], k.Key)
func (k *UniqueKeys) LocalizedString(p *message.Printer) string {
return p.Sprintf("items at %d and %d have same %s", k.Duplicates[0], k.Duplicates[1], k.Key)
}

// Example --
Expand Down
5 changes: 4 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@ module github.com/santhosh-tekuri/jsonschema/v6

go 1.21

require github.com/dlclark/regexp2 v1.11.0 // used for testing
require (
github.com/dlclark/regexp2 v1.11.0 // used for testing
golang.org/x/text v0.14.0
)
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
github.com/dlclark/regexp2 v1.11.0 h1:G/nrcoOa7ZXlpoa/91N3X7mM3r8eIlMBBJZvsz/mxKI=
github.com/dlclark/regexp2 v1.11.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8=
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
Loading

0 comments on commit f10de54

Please sign in to comment.