poppinss / indicative

Indicative is a simple yet powerful data validator for Node.js and browsers. It makes it so simple to write async validations on nested set of data.
https://indicative.adonisjs.com/
MIT License
417 stars 52 forks source link

Regex vaidation expect to end with $ #259

Open soubhikchatterjee opened 4 years ago

soubhikchatterjee commented 4 years ago

Package version

7.2.1

Node.js and npm version

Node: v12.4.0 npm: 6.13.7

Sample Code (to reproduce the issue)

Following code works:

 const rules = {
    username: [
      validations.required(),
      validations.regex(["^[a-zA-Z0-9._-]+$"])
    ]
  };

Following code does NOT work:

 const rules = {
    username: [
      validations.required(),
      validations.regex(["^[a-zA-Z0-9._-]+"])
    ]
  };

https://indicative.adonisjs.com/validations/master/regex The regex expects to end with $, otherwise it doesn't work

thetutlage commented 4 years ago

Can you share the inputs against which the regex are tested along with the expected behavior and the actual behavior

soubhikchatterjee commented 4 years ago

Kindly check the code i shared https://codesandbox.io/s/laughing-snow-py2h8?file=/src/index.js

There are two examples, example 1 works, example 2 does not work as expected.

soubhikchatterjee commented 4 years ago

@thetutlage Did you get a chance to look into the code samples?

Thanks