-1

I want to know how may I apply lowerCase() before the regex validation starts.

return {
   name: [
      rule('required')
      rule('regex', '/^(?=\S*[a-z])\S{8,}$/')
   ]
}  

How may I make name lowerCase before validation starts?

PlayHardGoPro
  • 2,320
  • 7
  • 36
  • 72

2 Answers2

1

You can use:

rule('regex', /^(?=\S*[a-z])\S{8,}$/i)

or

rule('regex', new RegExp('^(?=\S*[a-z])\S{8,}$', 'i'))

to match the regex with case-insensitive mode.

Tibebes. M
  • 4,961
  • 4
  • 9
  • 30
0

Please provide more information on what you are using to validate, and if you are using any library for the form itself.

From the information you provided, what I can suggest is that you make the regex expression case insensitive, and afterward, if you really need to make it lowercase, do it when the form submits before sending the information to the backend.

You can make the regex case insensitive by adding an i at the end of the regex expression after the last /.

Hope it helps.