bcardarella/client_side_validations — Issue #228: regular expression options/modifiers do not work
Author: astjohn
Created: 2011-12-01 01:05:54+00:00
State: open

I love this gem, but have just ran into an issue. Regular expressions with options break the javascript on the client side.

For example, the following:
`validates :whatever, format: {with: /[a-z]/ix}`

results in this error on the client side:
`Uncaught SyntaxError: Invalid flags supplied to RegExp constructor 'ix'`

This likely has to do with the way the regular expression is treated on the client side:

`window['some_model'] = {"format":{"message":"is invalid","with":/[a-z]/ix}}`

I haven't looked into this in depth yet. Would changing the json object there to use strings (using quotes) help?