Closed sumantaparida closed 1 year ago
Describe the bug Yup is not test multiple validation, I want to validate in one field like
min , max, oneOf and regex validate with one field.
This is the code
validations.forEach(Item => { if (Item.size) { fieldSchema = Yup.string().min(Item.size?.min, Item.message).max(Item.size?.max, Item.message); } if (Item.regexp) { fieldSchema = Yup.string().matches(Item.regexp.pattern, Item.message); } if (Item.in) { fieldSchema = Yup.string().oneOf(Item.in, Item.message || `List value ${Item.in}`); } });
Expected behavior A clear and concise description of what you expected to happen.
Platform (please complete the following information):
Additional context Add any other context about the problem here.
schema are immutable, your example is not setting multiple validations its only setting validations once because you aren't using fieldSchema in each if branch
fieldSchema
Describe the bug Yup is not test multiple validation, I want to validate in one field like
This is the code
Expected behavior A clear and concise description of what you expected to happen.
Platform (please complete the following information):
Additional context Add any other context about the problem here.