Skip to content
Snippets Groups Projects
Commit d6a9fec5 authored by Fatih20's avatar Fatih20
Browse files

Delete unused validator.

parent e99b3016
No related merge requests found
class Validator {
errors = {};
textLength( fieldName: string, text: string, min: number, max: number) {
let error = "";
if (text.length < min) {
error = `${fieldName} must be at least ${min} characters.`;
} else if (text.length > max) {
error = `${fieldName} must be at most ${max} characters.`;
}
return error;
}
required( fieldName: string, text: string) {
let error = "";
if (text.length === 0) {
error = `${fieldName} is required.`;
}
return error;
}
// validateForm(formData: any, validationRules: any) {
// this.errors = {};
// Object.entries(validationRules).forEach(([fieldName, rules]) => {
// const { required, min, max } = rules;
// const value = formData[fieldName];
// if (required) {
// const requiredError = this.required(value, fieldName);
// if (requiredError) {
// this.errors[fieldName] = requiredError;
// return;
// }
// }
// if (min !== undefined && max !== undefined) {
// const lengthError = this.textLength(value, min, max, fieldName);
// if (lengthError) {
// this.errors[fieldName] = lengthError;
// }
// }
// });
// return this.errors;
// }
}
export default Validator;
\ No newline at end of file
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment