Never used Joi before but it looks much more powerful (and heavy).
This library is just a few bytes, although it has all the basic pieces you need to build more Joi-ish stuff (I guess).
Something you can do with ts.data.json that I don't see in the Joi docs is mapping over a decoded value. For instance:
type User = {
id: number,
name: string,
dateOfBirth: Date
}
JsonDecoder.object<User>(
{
id: JsonDecoder.number,
name: JsonDecoder.string,
dateOfBirth: JsonDecoder.string.map(stringDate => new Date(stringDate)),
},
'User'
);
Never used Joi before but it looks much more powerful (and heavy).
This library is just a few bytes, although it has all the basic pieces you need to build more Joi-ish stuff (I guess).
Something you can do with
ts.data.json
that I don't see in the Joi docs is mapping over a decoded value. For instance:Very useful.
Thanks for pointing that out Thijs.
Cheers!
Mapping seems useful indeed :)
I use Joi on the server so size is not an issue there. For the browser I use yup. Similar API but much smaller footprint.
Interesting! smaller footprint but powerful too.
I might add an alternatives section in the
ts.data.json
docs.Thanks!