-
Notifications
You must be signed in to change notification settings - Fork 338
Open
Description
Description
When validating YAML input that contains the YAML 1.1 floating-point literal .nan, validation fails with a JsonParseException: Malformed numeric value '.nan' before any JSON Schema rules are applied. This occurs because Jackson’s YAML parser (used internally by this library) does not accept .nan as a valid numeric literal, even though it is permitted by YAML 1.1.
Example
Given this schema:
{
"type": "object",
"properties": {
"defaultValue": { "type": "number" }
}
}Yaml input
defaultValue: .nanCode example
fun validateYaml(yaml: String, schema: JsonNode) {
val violatedRules = registry
.getSchema(schema)
.validate(yaml, InputFormat.YAML) { executionContext ->
executionContext.executionConfig {
it.formatAssertionsEnabled(true)
}
}
.joinToString("\n")
require(violatedRules.isNotBlank()) {
"Validation failed:\n$violatedRules"
}
}
companion object {
private val registry = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_2020_12)
}Result
java.io.UncheckedIOException: Invalid input
Caused by: com.fasterxml.jackson.core.JsonParseException:
Malformed numeric value '.nan'
Expected Behavior
.nan should be parsed as a numeric value (NaN) and then validated against the schema.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels