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.

Multiple RegEx Per Key

See original GitHub issue

It was mentioned in #5 that regEx should support multiple regular expressions for a single schema key. This seems like a good idea. Might be best to name them rather than using an array, and then those names can be used for custom messages:

MySchema = new SimpleSchema({
  password: {
    type: String,
    regEx: {
      numbers: twoNumbersRegEx
    }
  }
});

MySchema.messages({
    'regEx.numbers': "[label] must have two numbers"
});

Issue Analytics

  • State:closed
  • Created 10 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
drewlsverncommented, Jun 1, 2016

I have tried implementing exactly as shown here, but it doesn’t seem to work. It just displays the default regEx error message “[label] failed regular expression validation”. Are there any known bugs with feature?

0reactions
aldeedcommented, Oct 2, 2013

Went with an array because of @sbking’s comment about validation order. Object key order isn’t 100% reliable as spec’d. You can still customize messages based on array index:

MySchema = new SimpleSchema({
  password: {
    type: String,
    regEx: [twoNumbersRegEx, twoSpecialCharactersRegEx]
  }
});

MySchema.messages({
    'regEx.0': "[label] must have two numbers"
});
Read more comments on GitHub >

github_iconTop Results From Across the Web

Multiple regex substitutions using a dict with ... - Stack Overflow
The closest solution I have found for this is to compile a regular expression from a dictionary of substitution targets and then to...
Read more >
RegExp - JavaScript - MDN Web Docs - Mozilla
Chrome Edge RegExp Full support. Chrome1. Toggle history Full support. Edge12. Toggle history @@match Full support. Chrome50. Toggle history Full support. Edge13. Toggle history @@matchAll Full...
Read more >
Matching Multiple Regex Patterns in Pandas | by Tim Oltman
Pandas provides several functions where regex patterns can be applied ... the method will return a DataFrame with one column for each group....
Read more >
Replacing Multiple Patterns in a Single Pass - O'Reilly
The keys are the set of strings (or regular-expression patterns) you want to replace, and the corresponding values are the strings with which...
Read more >
Best Practices for Regular Expressions in .NET - Microsoft Learn
In general, regular expressions can accept two types of input: ... means that the regular expression pattern must be recompiled each time ...
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