I made such a schema:
const schema = yup.object().shape({
seats: yup
.number()
.label('seats')
.required('pls enter'),
});
Additionally, I want to check that the number is positive or greater than 0. Is there any way I can add such a condition into the schema?
You can use .positive() and also .min(1)
const schema = yup.object().shape({
seats: yup
.number()
.positive()
.label('seats')
.required('pls enter')
.min(1),
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With