Skip to main content

invalid-regex-format

Rejects a schema pattern that Specmatic cannot compile as a regular expression.

AttributeValue
CategorySchema
MaturityPlatinum
OpenAPISwagger 2.0; OpenAPI 3.0, 3.1, 3.2
StarterOff
LenientWarning
Recommended–CompleteError

Intent

An invalid regex cannot reliably validate data and may fail later in tooling or runtime code.

Flags

Any schema pattern that is not valid according to Specmatic's regular-expression engine.

Does not flag

Valid patterns or schemas without pattern.

See it fail

postalCode:
type: string
pattern: '[0-9{5}'

Diagnostic: Invalid Regex format

Fix it

Close and quantify the character class correctly:

postalCode:
type: string
pattern: '^[0-9]{5}$'

Configure

profiles:
default:
rules:
extends: [recommended]
override:
invalid-regex-format: warn

Nearby: pattern-length-incompatible.