Closed BackdoorTech closed 2 years ago
when regular expression contains comma ',' example:
/[0-9]{1,8}/
Not working properly
i solved it this way
const data = { name: 'John Doe', company: 'Example Co.', birthday: '3123' }; const rules = { name: 'required', birthday: [`EMISREX: [0-9]{1,8}`], company: ['required', 'string'] }; const v = Valid.make(data, rules); function EMISREX (name, value, params) { if (typeof(params) === 'object') { var params = params.join() // convert array into string } params = params.replace(/\s*/,''); // remove spaces from the beginning of the text params = new RegExp(params); return value.match(params) !== null } v.extend('EMISREX', EMISREX, ':attr is not a valid mongo id'); if (v.fails()) { const errors = v.getErrors(); console.log(errors); }
I just test the code in working
This way won't work
const data = { name: 'John Doe', company: 'Example Co.', birthday: '3123' }; const rules = { name: 'required', birthday: [`regex: /[0-9]{1,8}/`], company: ['required', 'string'] }; const v = Valid.make(data, rules); if (v.fails()) { const errors = v.getErrors(); console.log(errors); }
I love your library!!!!
Hello 👋
I'll be checking this issue soon. Thanks for your patience.
when regular expression contains comma ',' example:
/[0-9]{1,8}/
Not working properly
i solved it this way
I just test the code in working
This way won't work
I love your library!!!!