-
Notifications
You must be signed in to change notification settings - Fork 7
Open
Description
Using ValidateInstance on DTDoubleInfo with either NaN, Infinity or -Infinity currently results in a violation, since this check is being made:
// In my case when using JsonSerializer.Serialize with
// NumberHandling = JsonNumberHandling.AllowNamedFloatingPointLiterals
// double.NaN becomes a JSON string "NaN"
if (instanceElt.ValueKind != JsonValueKind.Number)
{
violations.Add($">>{instanceElt.GetRawText()}<< is not a numeric value");
return false;
}
I have a few cases where some of my doubles can be double.NaN or double.PositiveInfinity
according to W3 NaN and infinity values are allowed: https://www.w3.org/TR/xmlschema-2/#double
I guess my suggestion would be to change the ValidateInstance methods to something like:
private bool ValidateInstanceV2(JsonElement instanceElt, string instanceName, List<string> violations)
{
if (!double.TryParse(instanceElt.GetRawText(), out double val))
{
violations.Add($"{instanceElt.GetRawText()} does not conform to the XSD definition of 'double'");
return false;
}
return true;
}
Do you see any issues with making this change?
Metadata
Metadata
Assignees
Labels
No labels