I have the following situation
I have a json file with certain regular expressions that i use to validate some fields
I get the data from the file within a service and inject the service into my directive
So in my directive i have
var alphanumeric = new RegExp(Rules.password.alphanumeric);
I'm using new RegExp
based on some answers in SO.
Then in order to do the validations:
pass_alphanumeric.test(newVal) // This way doesn't work
But if i do it with the Regex it does work.
/[A-z]/.test(newVal) // This works!
However if i do a console.log(pass_alphanumeric)
i get:
/[A-z]/
I'm kinda stuck in here and not sure how to do it,
Note I need to get it from a Json File since It's connected to the backend and the rules can be changed anytime by another person.
Aucun commentaire:
Enregistrer un commentaire