I recently created an interface for form validation. Here is the initial structure:
export interface SearchBarValidatorObj {
[k: string]: KeyObjectValidator;
}
However, I am wondering if there is a way to add a "static" type to it in order to achieve certain functionality. Would this modified version work?
export interface SearchBarValidatorObj {
required: string | boolean
[k: string]: KeyObjectValidator;
}
For reference, here is the KeyObjectValidator interface definition:
interface KeyObjectValidator {
value: string | number | RegExp;
message?: string;
}
Cheers!