First is, I want to validate the field that if the user type a character that is not existing in this (e.g.): /[ùûüÿ€’“”«»–àâæçéèêëïîôœ]/
the error message will be triggered from Yup.
Second is, I want to concatenate the 3 variables with Regex validation.
Here's the code:
const validChars1 = /[A-Za-z0-9`~!@#$%^&*()+={};:’”,./<>?| \\\\\ [\]]*$/;
const validChars2 = /[ùûüÿ€’“”«»–àâæçéèêëïîôœ]/;
const validChars3 = /[áéíóúüñ¿]/;
const mainValidator = validChars1 + validChars2 + validChars3;
const validationSchema = yup.object({
primaryInformation: yup.object({
externalEmployeeId: yup
.string()
.matches(mainValidator, "Please enter valid name")
.required(intl.get("userManagement.editor.requiredFieldError"))
//Error: Operator '+' cannot be applied to types 'RegExp' and 'RegExp'
Please help me out of this problem, thank you!