yoitsro / joigoose

Joi validation for your Mongoose models without the hassle of maintaining two schemas
MIT License
177 stars 19 forks source link

Allow to provide enum in string data type #24

Closed JeromeDeLeon closed 4 years ago

JeromeDeLeon commented 6 years ago

Like in mongoose that allows developers to provide enum validator like this:

var personSchema = new Schema({ .... gender: { type: String, enum: ['F', 'M'] } });

yoitsro commented 5 years ago

Hey @JeromeDeLeon, sorry about the delay. I'm a little busy at the moment, so I'm not sure when I'll have chance to look at this, but feel free to submit a PR and I'll take a look :)

g-div commented 4 years ago

If I undestand this correctly the values passed to .valid(...values) should be passed to the enum property. The problem I see there is that Joi implements .valid(...values) for any type, while mongoose only accept this property for keys of type String. Assumed it is ok that it will only works for strings, I will maybe try to submit a PR soon.

yoitsro commented 4 years ago

Closing this, but I'll reopen if necessary.