jhthorsen / json-validator

:cop: Validate data against a JSON schema
https://metacpan.org/release/JSON-Validator
56 stars 58 forks source link

fix joi required() with nested objects #264

Closed TimStallard closed 2 years ago

TimStallard commented 2 years ago

Summary

This PR fixes Joi's required() method when used with nested objects.

Motivation

Currently the required attribute is used for both the boolean flag of whether a property is required, and also to store the array of required properties. When used with nested objects, this either ends up with properties incorrectly being marked as required, or dying with Can't use string ("1") as an ARRAY ref while "strict refs" in use.

This PR moves the array of required properties into a separate attribute.