fastest-validator icon indicating copy to clipboard operation
fastest-validator copied to clipboard

Q: Object with random key:value validation

Open dougg0k opened this issue 3 years ago • 2 comments

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>; }

dougg0k avatar Aug 04 '22 21:08 dougg0k

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

icebob avatar Aug 13 '22 13:08 icebob

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.

dougg0k avatar Aug 13 '22 15:08 dougg0k