Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

257
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!