mirror of
https://github.com/Nezumi-2711/react-training.git
synced 2026-09-22 20:01:59 +00:00
Update name variable and optimzed code
This commit is contained in:
@@ -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),
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user