Newtonsoft.Json.Schema
Newtonsoft.Json.Schema copied to clipboard
simple normalizing operations as extension
Hey guys! We are using json.net schema for schema validation of incoming data (customer data). Sometimes we want to normalize some string fields: a. trim white spaces b. remove punctuation marks c. find and replace operation
We have a hacky implementation in place by extending the JSchemaValidatingReader
and calling the ValidateCurrentToken
using reflection, which isn't that great.
this is an example of how we pass the normalization directives on the json schema (you can see it on the Address
property)
{
"type": "object",
"properties": {
"Address": {
"normalize": {
"enabled": true,
"steps": [
{
"action": "trimWhitespace"
}
]
},
"type": "string"
},
"amount": {
"type": "number"
},
"Email": {
"type": "string",
"format": "email"
}
}
}
What do you think would be a better way of achieving this functionality?