question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

question: @Matches acting weird

See original GitHub issue

Hi there,

I think it is a bug, but I might be doing something wrong.

Description

See the following class:

class Example {
    @Matches(/^[0-9]{2}\/[0-9]{4}$/g)     // MM/YYYY format
    @IsOptional()
    from?: string;

    @Matches(/^[0-9]{2}\/[0-9]{4}$/g)     // MM/YYYY format
    @IsOptional()
    to?: string;
}

When I am only populating either of the fields, it works as expected.

const a = new Example();
a.from = "05/2017";

validate(a);    // gives no error

But when I am populating both fields, it gives me an error:

const a = new Example();
a.from = "05/2017";
a.to = "05/2020";

validate(a); // gives an error

from must match /^[0-9]{2}\\/[0-9]{4}$/g regular expression

There is an extra \ in the error message, it might have something to do with.

Environment

  • nodejs: 12
  • browser
  • framework/library

class-validator version: 0.11.1

If someone could have a look it would be appreciated. Cheers

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
Berger92commented, May 5, 2020

@vlapo Thanks again for taking a look.

I don’t think either. I don’t need g actually. I never came across this before, so I really appreciate your efforts.

0reactions
lock[bot]commented, May 20, 2020

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

15 Improv Games, Exercises & Activities for Adults in 2022
Improv games are acting exercises that require participants to react in real time ... Questions Only is an easy improv game for beginners....
Read more >
Awkward Question-and-Answer Game - YouTube
Awkward Question -and-Answer Game. Did you know that playing a "get to know you" game with your co-workers will build team morale?
Read more >
50 Get to Know You Games and Icebreakers - SignUpGenius
Start the conversation and get your group moving, talking and laughing with these icebreaker games and ideas that are guaranteed to build relationships...
Read more >
22 great improv games for better collaboration (and fun!)
Improv has its roots in schools of acting and comedy, and has often been used to warm-up actors and to build collaborative skills....
Read more >
Acting Games | Drama Exercises and Games for Kids and Adults
They help students get comfortable, warmed up and focused. Acting games also develop important skills required for acting and performing.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found