From b43ebcf61f456bc14fc7265a541eb2593702f09c Mon Sep 17 00:00:00 2001 From: YongHee Kim <42163454+yongheekim-dev@users.noreply.github.com> Date: Thu, 23 Jul 2020 01:18:32 +0900 Subject: [PATCH] treat `Missing` as `null` (#21) Co-authored-by: Oscar Dowson --- src/validation.jl | 1 + test/runtests.jl | 2 ++ 2 files changed, 3 insertions(+) diff --git a/src/validation.jl b/src/validation.jl index b4d4920..4744f7a 100644 --- a/src/validation.jl +++ b/src/validation.jl @@ -317,6 +317,7 @@ _is_type(::Bool, ::Val{:boolean}) = true _is_type(::Integer, ::Val{:integer}) = true _is_type(::Real, ::Val{:number}) = true _is_type(::Nothing, ::Val{:null}) = true +_is_type(::Missing, ::Val{:null}) = true _is_type(::AbstractDict, ::Val{:object}) = true _is_type(::String, ::Val{:string}) = true # Note that Julia treat's Bool <: Number, but JSON-Schema distinguishes them. diff --git a/test/runtests.jl b/test/runtests.jl index 540fc78..16b685d 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -276,6 +276,8 @@ end @test JSONSchema._is_type(val, Val(Symbol(key))) @test !JSONSchema._is_type(:not_a_json_type, Val(Symbol(key))) end + @test JSONSchema._is_type(missing, Val(:null)) + @test !JSONSchema._is_type(true, Val(:number)) @test !JSONSchema._is_type(true, Val(:integer)) end