tvkitchen / countertop

The entry point for developers who want to set up a TV Kitchen.
https://tv.kitchen
GNU Lesser General Public License v3.0
6 stars 2 forks source link

Let's consider a validator #166

Closed slifty closed 2 years ago

slifty commented 2 years ago

I recently added a type guard to make payload deserialization safer -- it's written in vanilla javascript which, while certainly fast, is a bit verbose. I explored this a bit in #163.

Joi is a popular and powerful validator, but it is apparently maybe a bit slow. Speed is a major consideration here because of the volume of data that is going to be validated in short time spans.

Ajv is way more used and also, it seems, faster maybe even to the tune of 100x. I get the sense it is less powerful but since we really are just trying to validate at a schema level I think that power would not be needed, and we would value the speed.

All this is to say: I think it would be appropriate for TV Kitchen to add ajv as a dependency and use it to validate all inputs.