justarrived / just-match-web

JustMatch Web
https://app.justarrived.se
5 stars 1 forks source link

Consider using ng4 built in email validator #466

Closed buren closed 7 years ago

buren commented 7 years ago

Ng4 now has a email directive/validator

bex1 commented 7 years ago

Will use.

Also to be consitent the api should use the same regex as that new validator so they complain about the same things:

const EMAIL_REGEXP = /^(?=.{1,254}$)(?=.{1,64}@)[-!#$%&'*+/0-9=?A-Z^_`a-z{|}~]+(\.[-!#$%&'*+/0-9=?A-Z^_`a-z{|}~]+)*@[A-Za-z0-9]([A-Za-z0-9-]{0,61}[A-Za-z0-9])?(\.[A-Za-z0-9]([A-Za-z0-9-]{0,61}[A-Za-z0-9])?)*$/;

@buren

buren commented 7 years ago

Yeah, that would be great 👍 Now its just a matter of figuring out how to convert that JS-regex into a Ruby one without altering the meaning and I'm no pro-regexer 😉

Took a stab at just changing the start- and end-syntax, but ended up with this error:

irb(main):003:0> EMAIL_REGEXP = /\A(?=.{1,254}$)(?=.{1,64}@)[-!#$%&'*+/0-9=?A-Z^_`a-z{|}~]+(\.[-!#$%&'*+/0-9=?A-Z^_`a-z{|}~]+)*@[A-Za-z0-9]([A-Za-z0-9-]{0,61}[A-Za-z0-9])?(\.[A-Za-z0-9]([A-Za-z0-9-]{0,61}[A-Za-z0-9])?)*\Z/i
SyntaxError: (irb):3: premature end of char-class: /\A(?=.{1,254}$)(?=.{1,64}@)[-!#$%&'*+/
(irb):3: syntax error, unexpected tINTEGER, expecting end-of-input
...,254}$)(?=.{1,64}@)[-!#$%&'*+/0-9=?A-Z^_`a-z{|}~]+(\.[-!#$%&...
...                               ^
    from /usr/bin/irb:12:in `<main>'
bex1 commented 7 years ago

bleh. Why so many conventions.......... kill me pls

buren commented 7 years ago

Yeah, there are quite a few Ruby to JavaScript regex converters, but not the other way way around 😕