I'm trying to validate a form with react. Having main Controller, which has the model and handles the actual validation. Passing down model to child controllers, as well the validation errors.
How can i create an array which contains these errors, the array has a key which is a field name in the model, and value is the validation error message. I want to bind the models field names to the error message. Class for example what im looking for.
export class Model {
SampleNumber: number;
SampleString: string;
Errors: [keyof Model, string];
}
Or is there a preferred way of handling validation messages in React with typescript.
Errorsif you want it to be contain key-value pairs.