Skip to content

Commit

Permalink
treat Missing as null (#21)
Browse files Browse the repository at this point in the history
Co-authored-by: Oscar Dowson <[email protected]>
  • Loading branch information
YongHee Kim and odow authored Jul 22, 2020
1 parent 5b8487e commit b43ebcf
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/validation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit b43ebcf

Please sign in to comment.