Update name variable and optimzed code

This commit is contained in:
2023-10-27 14:15:47 +07:00
parent e95ac9c4ca
commit cce36788ac
2 changed files with 32 additions and 40 deletions
+12 -3
View File
@@ -28,10 +28,19 @@ const getPropValues = (stateSchema: TStateSchema, prop?: TPropValues) => {
}, {} as TKeyValue);
};
const addValidator = (func: (input: string) => boolean, error: string) => {
type test = {
validatorFunc: (value: string) => boolean;
prop: string;
required?: boolean;
};
const addValidator = ({ validatorFunc, prop, required = true }: test) => {
return {
func: func,
error: invalidFormatMessage(error),
required: required,
validator: {
func: validatorFunc,
error: invalidFormatMessage(prop),
},
};
};