don't want to write each field test . I want overall test .please help me #9225
-
const schema = yup.object().shape({ |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 5 replies
-
Don't think there is alternative, schema will need to declare each input validation rules. |
Beta Was this translation helpful? Give feedback.
-
You can simply create a validation schema base / factory and extend it with field specific operators like: const createBaseFieldSchema = (name: string) =>
yup.string().required(`${name} is Required`).test("", "Remove white spaces", (value) => !!value.trim())
const schema = yup.object({
tax: createBaseFieldSchema("tax").min(2, "2 MIN")
}) |
Beta Was this translation helpful? Give feedback.
-
It is not working.please check |
Beta Was this translation helpful? Give feedback.
It is not working.please check
codesandbox