How to set an exception for the name validator prompt

For the Classic Travels bot - x1648806732738, the name validator is failing when we give the name “Usama”.
Is there any way we can set an exception for this validation?

Hi Rishabh,
A better way would be if you write your own custom validator if the inbuilt platform validator fails.
You can also check the different Unicode validations one can use in regex to validate different local languages if any.
Reference: Regex Tutorial - Unicode Characters and Properties

Example of a validator:
return new Promise(resolve => {
// name validator in different languages in Unicode(developed by Subhrajit Gupta)
console.log(data.message, ‘in name validator’)
let nameRegex = /[1]+$/gm;
const message = data.message
console.log(message.match(“[2]+$”), “name in hindi”)
if (message.match(/[3]+$/u)) { // hindi
console.log(‘in hindi’)
return resolve(message)
}
else if (message.match(/[4]+[\u0bbe-\u0bcd\u0bd7]?$/u)) { // tamil [\u0bbe-\u0bcd\u0bd7]?
console.log(‘in tamil’)
return resolve(message)
}
else if (message.match(/[5]+$/u)) { // kannada
console.log(‘in kannada’)
return resolve(message)
}
else if (message.match(/[6]+$/u)) { // telugu
console.log(‘in telugu’)
return resolve(message)
}
else if (message.match(/[7]+$/u)) { // bengali
console.log(‘in bengali’)
return resolve(message)
}
else if (message.match(nameRegex)) {
console.log(‘in english’)
return resolve(message)
}
else {
resolve(‘incorrect_name101’)
}
});
If you are using only English then you can use a regeX like this:
const nameRegex = /[8]+$/gm; or,
const nameRegexEnglish = /[9]{3,30}$/gm;
where users get to type A-Z, a-z, space, or at max a dot if they type by mistake.
Now, there are some stop words that can’t be a part of the name.
You can keep all such stopwords in an array and check if anyone exists in the name.
If it does, it’s not a valid name, else it is.

If in case, you want the platform validator to work without exception, please raise a ticket to the platform team for the same. Else you can design your own custom Validator.

Hope it helps!

PS: The ^ and the regex are getting blurred it seems. Please click the icon to get the regex and add ^ in front.


  1. A-Za-z. ↩︎

  2. \u0900-\u097F. ↩︎

  3. \u0900-\u097F. ↩︎

  4. \u0b80-\u0bff . ↩︎

  5. \u0C80-\u0CFF . ↩︎

  6. \u0C00-\u0C7F . ↩︎

  7. \u0980-\u09FF . ↩︎

  8. A-Za-z. ↩︎

  9. a-zA-Z ↩︎

1 Like