Closed WesTyler closed 7 years ago
Using the Joi schema Joi.object().pattern() should be supported in both .entityFor and .example methods.
Joi.object().pattern()
.entityFor
.example
const schema = Joi.object().pattern(/^(\{){0,1}[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}(\}){0,1}$/, Joi.object().keys({ id : Joi.string().guid().required(), tags: Joi.array().items(Joi.string()).required() })).min(2); const example = Felicity.example(schema);
example /* { '4dffdb09-9e60-423d-b956-a9b821fb8fde': { id: '4dffdb09-9e60-423d-b956-a9b821fb8fde', tags: [] }, '3ad38506-3ef4-4e93-a745-023f8e8ccf75': { id: '3ad38506-3ef4-4e93-a745-023f8e8ccf75', tags: [] } } */
Only the .min(2) is respected. Example fails validation.
.min(2)
example /* { wdgx: 'wdgx6obscdnbrtz9kldavpldi', ppfz: 'ppfzbv353bdllftgdzllq5mi' } */
Currently hacking on this between diaper changes
Context
What are you trying to achieve or the steps to reproduce ?
Using the Joi schema
Joi.object().pattern()
should be supported in both.entityFor
and.example
methods.What result did you expect ?
What result did you observe ?
Only the
.min(2)
is respected. Example fails validation.