From ba5eab4d295745f4a7b57b786ada689b00c172f1 Mon Sep 17 00:00:00 2001 From: Jaime Soriano Pastor Date: Thu, 12 Mar 2026 18:00:22 +0100 Subject: [PATCH 1/3] Add dependabot and github action to run tests, remove travis --- .github/dependabot.yml | 11 +++++++++++ .github/workflows/test.yml | 15 +++++++++++++++ .travis.yml | 9 --------- 3 files changed, 26 insertions(+), 9 deletions(-) create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/test.yml delete mode 100644 .travis.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 00000000..aafb8a27 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,11 @@ +version: 2 +updates: + - package-ecosystem: github-actions + directory: / + schedule: + interval: weekly + + - package-ecosystem: gomod + directory: / + schedule: + interval: weekly diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 00000000..4a1b75fa --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,15 @@ +name: Test + +on: + push: + pull_request: + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 + with: + go-version: stable + - run: go test ./... diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 3289001c..00000000 --- a/.travis.yml +++ /dev/null @@ -1,9 +0,0 @@ -language: go -go: - - "1.11" - - "1.12" - - "1.13" -before_install: - - go get github.com/xeipuuv/gojsonreference - - go get github.com/xeipuuv/gojsonpointer - - go get github.com/stretchr/testify/assert From c671702613b27a9a83041eb57064f14c99386d34 Mon Sep 17 00:00:00 2001 From: Jaime Soriano Pastor Date: Thu, 12 Mar 2026 18:00:33 +0100 Subject: [PATCH 2/3] Fix issues with tests --- format_checkers.go | 7 +++++++ schemaLoader.go | 1 + 2 files changed, 8 insertions(+) diff --git a/format_checkers.go b/format_checkers.go index 1e770464..038bccf8 100644 --- a/format_checkers.go +++ b/format_checkers.go @@ -257,12 +257,19 @@ func (f DateFormatChecker) IsFormat(input interface{}) bool { } // IsFormat checks if input correctly formatted time (HH:MM:SS or HH:MM:SSZ-07:00) +// per RFC3339, which does not allow comma as a decimal separator (unlike ISO 8601). func (f TimeFormatChecker) IsFormat(input interface{}) bool { asString, ok := input.(string) if !ok { return true } + // RFC3339 does not permit comma as a fractional seconds separator (ISO 8601 does). + // Go's time.Parse accepts both, so we must reject commas explicitly. + if strings.ContainsRune(asString, ',') { + return false + } + if _, err := time.Parse("15:04:05Z07:00", asString); err == nil { return true } diff --git a/schemaLoader.go b/schemaLoader.go index 20db0c1f..7c2f0e11 100644 --- a/schemaLoader.go +++ b/schemaLoader.go @@ -35,6 +35,7 @@ func NewSchemaLoader() *SchemaLoader { ps := &SchemaLoader{ pool: &schemaPool{ schemaPoolDocuments: make(map[string]*schemaPoolDocument), + jsonLoaderFactory: DefaultJSONLoaderFactory{}, }, AutoDetect: true, Validate: false, From 85dde8b5932880c90536b98c3ba7a3f5c1401a82 Mon Sep 17 00:00:00 2001 From: Jaime Soriano Pastor Date: Thu, 12 Mar 2026 18:00:37 +0100 Subject: [PATCH 3/3] Update go.mod, fix further code issues --- .github/workflows/test.yml | 8 +++++++- go.mod | 8 ++++++-- go.sum | 4 ++-- schemaReferencePool.go | 9 +++------ 4 files changed, 18 insertions(+), 11 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4a1b75fa..c57b9d4f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -7,9 +7,15 @@ on: jobs: test: runs-on: ubuntu-latest + strategy: + matrix: + go-version: + - "1.25" + - "1.26" steps: - uses: actions/checkout@v4 - uses: actions/setup-go@v5 with: - go-version: stable + go-version: ${{ matrix.go-version }} + - run: go vet ./... - run: go test ./... diff --git a/go.mod b/go.mod index 08a28b55..89d943f6 100644 --- a/go.mod +++ b/go.mod @@ -1,10 +1,14 @@ module github.com/elastic/gojsonschema -go 1.16 +go 1.25 require ( github.com/stretchr/testify v1.3.0 github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 ) -require github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f // indirect +require ( + github.com/davecgh/go-spew v1.1.0 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect + github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect +) diff --git a/go.sum b/go.sum index 0e865ac7..592b2c84 100644 --- a/go.sum +++ b/go.sum @@ -5,7 +5,7 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f h1:J9EGpcZtP0E/raorCMxlFGSTBrsSlaDGf3jU/qvAE2c= -github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= +github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb h1:zGWFAtiMcyryUHoUjUJX0/lt1H2+i2Ka2n+D3DImSNo= +github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 h1:EzJWgHovont7NscjpAxXsDA8S8BMYve8Y5+7cuRE7R0= github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ= diff --git a/schemaReferencePool.go b/schemaReferencePool.go index 6e5e1b5c..7573b2a7 100644 --- a/schemaReferencePool.go +++ b/schemaReferencePool.go @@ -25,9 +25,6 @@ package gojsonschema -import ( - "fmt" -) type schemaReferencePool struct { documents map[string]*subSchema @@ -44,12 +41,12 @@ func newSchemaReferencePool() *schemaReferencePool { func (p *schemaReferencePool) Get(ref string) (r *subSchema, o bool) { if internalLogEnabled { - internalLog(fmt.Sprintf("Schema Reference ( %s )", ref)) + internalLog("Schema Reference ( %s )", ref) } if sch, ok := p.documents[ref]; ok { if internalLogEnabled { - internalLog(fmt.Sprintf(" From pool")) + internalLog(" From pool") } return sch, true } @@ -60,7 +57,7 @@ func (p *schemaReferencePool) Get(ref string) (r *subSchema, o bool) { func (p *schemaReferencePool) Add(ref string, sch *subSchema) { if internalLogEnabled { - internalLog(fmt.Sprintf("Add Schema Reference %s to pool", ref)) + internalLog("Add Schema Reference %s to pool", ref) } if _, ok := p.documents[ref]; !ok { p.documents[ref] = sch