'yup validation to Validate formki field whether starts with value of other input field
I have 2 fields in my form say carriercode and billnum, here I need to validate number should always have value of carriercode as a prefix, ex if carriercode=ABCD blnum should be ABCD followed by any charter can be string or number.
return Yup.object({
carriercode: Yup.string().required(requiredMessage).min(4,"length should be 4").matches(/^[a-zA-Z0-9-]+$/,"Can not contain special characters like ),(,@ etc."),
blnum: Yup.string().required(requiredMessage) //validate if blnum starts with carriercode
})
}
is there any way to achieve this using yup validations, to be simple I need something like startsWith/indexOf functionality in yup.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
