json-schema-generator icon indicating copy to clipboard operation
json-schema-generator copied to clipboard

Mocha/Chai deep.equal fails when validating

Open IoT-master opened this issue 8 years ago • 1 comments

I am using your json schema to validate two endpoints/responses, and I am having trouble using a working validator. The only one that works well, and with complex JSON is the deep.equal in Mocha/Chai.

The issue occurs when the required field appears with an array and not consistently in the same order, which deep.equal flags as a fail. Could you possible sort the required array, or at least produce an array that's consistently in the same order? That would really help me out.

IoT-master avatar Nov 17 '16 21:11 IoT-master

"required": [ "high" "low_moderate" "low" "moderate" "moderate_high" ]

is compared to:

"required": [ "moderate_high" "high" "moderate" "low_moderate" "low" ]

as a fail (as an example)

IoT-master avatar Nov 17 '16 21:11 IoT-master