Would you consider tuple as a first-class concept in Joi?
(and be interested in a PR?)
Consider, a query param foo=bar:baz an a schema like:
query: {
foo: Joi.tuple(':', Joi.string().min(3), Joi.string().guid())
}
// would fail on 'baz' not being a guid
I would expect tuple to
In my _particular_ case, I need to be able to validate
GET /entities?relationship=someUserString:someObjectGUID
And using regex can quickly get ugly.
That's what JSON serialization is for, why would you do your own thing ?
Thanks for the quick reply. Not all clients are producing/consuming JSON, but in my case I can make do. It's a bit more verbose and by default logging doesn't look as good but it seems to allow even more powerful validation. Thanks again.
I'm not going to put a parser for an obscure serialization format into core anyway :-)
those obscure delimited values :poodle:
Obscure format ?
If I want to follow a standard like this for example :
http://jsonapi.org/format/#fetching-sorting
example: "http://..../...?sort=-updated,author,name"
Sure, if I can do my own format, I can use the ones available in Joi, it's sufficient, but well,
If I have to follow JSON API standard, then I cannot parse the values with Joi...
You can now, with a custom joi type, see Joi.extend(). I don't want to implement string parsing into joi as I don't consider this to be core-worthy, many formats exist and I don't have enough time to support everything that's out there on my own.
This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions.
Most helpful comment
You can now, with a custom joi type, see Joi.extend(). I don't want to implement string parsing into joi as I don't consider this to be core-worthy, many formats exist and I don't have enough time to support everything that's out there on my own.