0

I've the following schema

var schema = {
    "$id": "postClientSchema.json",
    "type": "object",
    "definitions": {},
    "$schema": "http://json-schema.org/draft-06/schema#",
    "additionalProperties": false,
    "dynamicDefaults": {
        "Type": "gettype"
    },
    "properties": {
        "ID": {
            "type": "integer"
        },
        "Name": {
            "type": "string"
        },
        "Type": {
            "type": "integer"
        }

    }
}

I wish to overwrite the value of Type in incoming payload by the value I get from dynamicDefaults. gettype is a custom function which returns me value for type property.

I'm using AJV for schema validation. Thank you

Kshateesh
  • 571
  • 1
  • 8
  • 21
  • I think you're asusming JSON Schema does something it does not. JSON Schema is for validating JSON. It does not do anything TO the JSON instance being validated. – Relequestual Jun 08 '18 at 15:58
  • Thank you @Relequestual. But I wish if I could bring this functionality to my schema using AJV – Kshateesh Jun 10 '18 at 07:06
  • If you want more advanced validation, you might consider looking for a JSON validation library. – Relequestual Jun 11 '18 at 08:21
  • Yes, I'm using Advance Schema Validator (AJV) and I wonder if AJV can do that. – Kshateesh Jun 11 '18 at 09:03
  • You cannot do this with using JSON Schema. You need to use something else to validate your JSON in the way you want. – Relequestual Jun 11 '18 at 09:14
  • Okay. can you tell me if my json schema validator( AJV: Another JSON Schema Validator -- for NodeJs) do this?? – Kshateesh Jun 15 '18 at 11:42
  • "You cannot do this with using JSON Schema." - That means, anything that uses JSON Schema to do validation, WILL NOT do what you want. You need something that DOES NOT use JSON Schema to do what you want. – Relequestual Jun 15 '18 at 12:22

0 Answers0