diff --git a/libs/jsonschema/schema.go b/libs/jsonschema/schema.go index 57082dc8..83213791 100644 --- a/libs/jsonschema/schema.go +++ b/libs/jsonschema/schema.go @@ -168,11 +168,6 @@ func (schema *Schema) validateSchemaPattern() error { return fmt.Errorf("invalid regex pattern %q provided for property %q: %w", pattern, name, err) } - // validate default value against the pattern - if property.Default != nil && !r.MatchString(property.Default.(string)) { - return fmt.Errorf("default value %q for property %q does not match specified regex pattern: %q", property.Default, name, pattern) - } - // validate enum values against the pattern for i, enum := range property.Enum { if !r.MatchString(enum.(string)) { diff --git a/libs/jsonschema/schema_test.go b/libs/jsonschema/schema_test.go index 8826a32b..a750f44a 100644 --- a/libs/jsonschema/schema_test.go +++ b/libs/jsonschema/schema_test.go @@ -175,7 +175,7 @@ func TestSchemaValidateIncorrectRegex(t *testing.T) { assert.EqualError(t, s.validate(), "invalid regex pattern \"(abc\" provided for property \"foo\": error parsing regexp: missing closing ): `(abc`") } -func TestSchemaValidatePatternDefault(t *testing.T) { +func TestSchemaDefaultValueIsNotValidatedAgainstPattern(t *testing.T) { s := &Schema{ Properties: map[string]*Schema{ "foo": { @@ -185,17 +185,6 @@ func TestSchemaValidatePatternDefault(t *testing.T) { }, }, } - assert.EqualError(t, s.validate(), "default value \"def\" for property \"foo\" does not match specified regex pattern: \"abc\"") - - s = &Schema{ - Properties: map[string]*Schema{ - "foo": { - Type: "string", - Pattern: "a.*d", - Default: "axyzd", - }, - }, - } assert.NoError(t, s.validate()) }