Skip to content

incorrect error for allOf in requirements #143

Description

@gproskurin

For some types of schema, error returned by jesse:validate_with_schema cannot be passed to jesse_error:to_json. Probably, mix of allOff/required yields such error.

Schema:

#{<<"$schema">> => <<"http://json-schema.org/draft-04/schema#">>,
  <<"properties">> => #{
    <<"field1">> => #{
      <<"type">> => <<"string">>
    }
  },
  <<"type">> => <<"object">>,
  <<"allOf">> => [
    #{<<"required">> => [<<"field1">>]}
  ]
}

Validate empty maps against this schema (which correctly returns error):

Err = jesse:validate_with_schema(Schema, #{})

result:

{error,[{data_invalid,#{<<"$schema">> =>
                            <<"http://json-schema.org/draft-04/schema#">>,
                        <<"allOf">> => [#{<<"required">> => [<<"field1">>]}],
                        <<"properties">> =>
                            #{<<"field1">> => #{<<"type">> => <<"string">>}},
                        <<"type">> => <<"object">>},
                      {all_schemas_not_valid,[{data_invalid,#{<<"required">> =>
                                                                  [<<"field1">>]},
                                                            missing_required_property,<<"field1">>,[]}]},
                      #{},[]}]}

Convert Err to json:

jesse_error:to_json(Err).
** exception error: bad argument
     in function  jsx_parser:value/4 (/Users/gpr/src/jesse/_build/default/lib/jsx/src/jsx_parser.erl, line 163)

Erlang version 26.2.5.21
In jesse version 1.5.3 this error didn't exist, in recent 1.8.2 it exists

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions