icebob / fastest-validator

:zap: The fastest JS validator library for NodeJS
MIT License
1.42k stars 89 forks source link

Q: Object with random key:value validation #302

Open dougg0k opened 2 years ago

dougg0k commented 2 years ago

Hi,

In the validation here, I have the validation below for, since there are random key:value, that can be put on.

data: {
    type: "object",
    empty: true,
},

What I want to ask, is there a way to validate the value type in these random (key:value)?

Like have the random values only be type string | number | boolean.

e.g., in typescript { data: Record<string, string | number | boolean>; }

icebob commented 2 years ago

Maybe it will be a solution? https://github.com/icebob/fastest-validator/issues/276

dougg0k commented 2 years ago

It seems it's only making a way to expect the key to be one or the other, though if they support the multi validation type for the value, it could work.

I have a object with random data, that data is key string and value can be string, number, boolean, object or even an array. That's what I am looking to validate, have the options to set what kind of random values it can be expect in that object, in their random keys.