Skip to content
This repository was archived by the owner on Apr 19, 2022. It is now read-only.

Regex vaidation expect to end with $ #259

Open
soubhikchatterjee opened this issue May 4, 2020 · 3 comments
Open

Regex vaidation expect to end with $ #259

soubhikchatterjee opened this issue May 4, 2020 · 3 comments

Comments

@soubhikchatterjee
Copy link

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
Copy link
Member

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

@soubhikchatterjee
Copy link
Author

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
Copy link
Author

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

Thanks

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants