Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

220
Visualizações
How do i prevent formik yup ( regex ) validation from disappearing

This is my regex

        const firstNameSpecialChars = /[^\/\\#+()$~%.":;*<>{}@]/;

This is my validation

     const validationSchema = Yup.object().shape({
    email: Yup.string()
      .email(ENTER_VALID_EMAIL_MESSAGE)
      .required(EMAIL_IS_REQUIRED_MESSAGE),
    firstname: Yup.string()
      .trim()
      .matches(
        firstNameSpecialChars,
        'These characters are not allowed in name fields',
      ),

I want an error to be shown when there is a regex match. This works, but there is a problem... As soon as i type after the hash symbol the error disappears but when there is a symbol the error shows up

enter image description here

This is how my error looks like when I type regex chars

enter image description here

which is not what i want if there is special char i want the error to be there till the user removes the special char


about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Found a solution :

I had to do this :

Regex

/^[^#+()$~%.":;*<>{}@\\/\\]+$/

This gives me the error when anyone of the stuff inside the [ ] matches

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda