Closed Farjaad closed 3 months ago
Unfortunately, this is a known issue: https://github.com/davishmcclurg/json_schemer/issues/167#issuecomment-1974909924
J
SONSchemer.schema
still doesn't support invalid schemas (and likely won't). I don't want every schema object to have to take the hit of validating the provided schema before parsing. When working with schemas that are potentially invalid, it's best to check them withJSONSchemer.valid_schema?
first.Now that I think of it,
JSONSchemer::Schema#valid_schema?
andJSONSchemer::Schema#validate_schema
were probably mistakes to begin with—may want to deprecate in the future.
Please use JSONSchemer.valid_schema?
(or JSONSchemer.validate_schema
) instead:
schema_definition = {
"type" => "string",
"pattern" => "/(/",
}
JSONSchemer.validate_schema(schema_definition).map { _1["error"] }
# ["value at `/pattern` does not match format: regex"]
The following raises a
RegexpError
instead of reporting that the regex is invalidResult:
end pattern with unmatched parenthesis: /\/(\// (RegexpError)