fredo-dedup / JSONSchema.jl

JSON Schema validation package for Julia
Other
31 stars 12 forks source link

Is validate(x::Dict, shcema) is necessary? #19

Closed YongHeeK closed 4 years ago

YongHeeK commented 4 years ago

validate methods seems generic enough to extended for AbstractDict. Is thres reason for allow only Dict for validate?

This is MWE

using JSONSchema
using OrderedCollections

schema = Schema("""{
    "\$schema": "http://json-schema.org/draft-07/schema",
    "\$id": "test.json",
    "type": "object",
    "title": "test",
    "required": [
        "Key"
    ],
    "additionalProperties": true,
    "properties": {
        "Key": {
            "type": "string",
            "enum": ["A", "B"] 
        }
    }
}""")

data = Dict("Key" => "A")
validate(data, schema) 

# validation fail
data2 = OrderedDict("Key" => "A")
validate(data2, schema) 
odow commented 4 years ago

No reason. Shouldn't be much trouble to go through and relax the type signatures.

odow commented 4 years ago

Closed by #20