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.

.matches() doesn't work

See original GitHub issue

I tried using: req.assert('field', 'error').matches(/myregex/); Is this the right way to call the method ‘matches’? Because chriso/validator.js uses matches(str, pattern [, modifiers]).

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
martinliptakcommented, Jun 1, 2018

This doesn’t work:

checkSchema({
  name: {
     matches: /\.(pdf)|(doc)|(docx)|(rtf)$/g
  }
})

This works:

checkSchema({
  name: {
    matches: {
      options: [/\.(pdf)|(doc)|(docx)|(rtf)$/, 'g']
    }
  }
})
1reaction
smarkdurbincommented, Mar 22, 2018

.matches() is not working.

*EDIT: It looks like you MUST set the “modifiers” param in this function for it to work and remove it from your pattern param Ex: (this is in my controller for a data type called ‘viewers’)

// // Validate fields.
    body('viewer_name').isLength({ min: 1 }).trim().withMessage('Viewer Name must be specified.')
        .matches(/^([0-9A-z\ \_]+)$/, 'g').withMessage('<strong>Viewer Name</strong> contains invalid characters<br>&nbsp; &#x21B3; upper/lower case letters, numbers, and underscores only')
Read more comments on GitHub >

github_iconTop Results From Across the Web

java - Regex doesn't work in String.matches() - Stack Overflow
Welcome to Java's misnamed .matches() method... It tries and matches ALL the input. Unfortunately, other languages have followed suit :(.
Read more >
Excel MATCH Function Error Troubleshooting Examples
Before we start troubleshooting the MATCH function, here's a short video that shows how the function works. It has four MATCH examples, ...
Read more >
Why isn't the Java matches method working? (Java pattern ...
The matches() method attempts to match the entire input ... The find method does not require your pattern to match the entire String....
Read more >
How to correct a #N/A error in INDEX/MATCH functions
Problem: There is no data to match. When the MATCH function does not find the lookup value in the lookup array, it returns...
Read more >
How to Fix Excel MATCH Function Errors - YouTube
Sometimes the Excel MATCH function returns an error, even if the lookup value is in the lookup list.This video shows two common causes...
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