Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EnablestrictExample for entityFor instances. #31

Closed
WesTyler opened this issue Oct 27, 2016 · 0 comments
Closed

EnablestrictExample for entityFor instances. #31

WesTyler opened this issue Oct 27, 2016 · 0 comments

Comments

@WesTyler
Copy link
Member

The below should be accurate. Right now, passing strictExample to entityFor does not persist the config for future .example() calls on instances.


  • strictExample - default false. Default behavior is to not run examples through Joi validation before returning.

If set to true, example will be validated prior to returning.

Note: in most cases, there is no difference. The only known cases where this may result in no example coming back are with regex patterns containing lookarounds.

const schema = Joi.object().keys({
    name    : Joi.string().regex(/abcd(?=efg)/)
});

const instance = new (Felicity.entityFor(schema)); // instance === { name: null }
const mockInstance = instance.example(); // mockInstance === { name: 'abcd' }

const strictInstance = new (Felicity.entityFor(schema, { config: { strictExample: true } })); strictInstance === { name: null }
const mockStrict = strictInstance.example(); // ValidationError
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant