I am using NJsonSchema to validate a Json against a JsonSchema.
Here is the code snippet. My current code is case-sensitive and validates only RED, and BLUE for enum color.
I want to validate the JObject(JSON) case-insensitively against the Enum Color so that it validates RED, Red, red, BLUE, Blue, blUE, etc. I am retrieving the color enum from a library so I don't have control over it.
Are there any annotations or validation settings that I can use?
public class ColorTypes
{
[Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))]
public Color[] Fill { get; set; }
}
// Color is an enum
public enum Color {
RED,
BLUE
}
// JsonSchema Creation
JsonSchema ColorSchema = JsonSchema.FromType<ColorTypes>();
// Here is my validation
public ICollection<ValidationError> validateJsonWithSchema(JsonSchema schema, JObject jsonObject)
{
ICollection<ValidationError> validationResult = schema.Validate(jsonObject);
return validationResult;
}