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

258
Vistas
Typescript creating an array of rules and getting

I am just starting out with Typescript in vue.js. I am trying to create an array of rules to validate an email.

in my data portion I have the following code

data(): {
    loading:  boolean,
    valid: boolean,
    emailRules: any[],
} {  
    return {
        loading: false,
        valid: true,
        emailRules: [
            v => !!v || "Email is required",
            v => /.+@.+\..+/.test(v) || "Email must be valid"
        ],
    }
},

I am getting a Parameter 'v' implicitly has an 'any' type error for the code above. I figured because it is a rule I could use any for my array type but I am wrong. So type should my array be so I don't have this error?

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

You should type the v payload like :

        emailRules: [
            (v : string) => !!v || "Email is required",
            (v : string) => /.+@.+\..+/.test(v) || "Email must be valid"
        ],
over 4 years ago · Santiago Trujillo 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