Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

184
Vistas
Using Angular Validators to create a restriction of 6-12 characters, but NOT of length 9

I am trying to create a Angular Validator that allows me to validate a string of both letters and characters of lengths 6-12 inclusive, but not of length 9.

I have tried

RegexAlphaNumeric = "^[a-zA-Z0-9]{6,8}|[a-zA-Z0-9]{10,12}$";
userId: ['', [Validators.minLength(6), Validators.maxLength(12),Validators.pattern(this.RegexAlphaNumeric)],],

Wondering if my usage of minLength and maxLength should not be used here and if there is a way to just utilize Validators.pattern() for this method.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You could either use a negative lookahead to assert not 9 characters:

^(?![a-zA-Z0-9]{9}$)[a-zA-Z0-9]{6,12}$

See a regex101 demo.

Or use an alternation as you already have in your question, but you have to group the parts between the start and the end of the string or else the pattern would match either 6-8 chars from the start or 10-12 chars at the end only.

^(?:[a-zA-Z0-9]{6,8}|[a-zA-Z0-9]{10,12})$

See a regex101 demo.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda