diff --git a/src/middleware/validator.tsx b/src/middleware/validator.tsx deleted file mode 100644 index fa760eaeee49cf3d96a7633d76831f94b9d22d6c..0000000000000000000000000000000000000000 --- a/src/middleware/validator.tsx +++ /dev/null @@ -1,50 +0,0 @@ -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