mirego/activerecord_json_validator — pull request #2 by remiprev (2013-11-18 18:52:43+00:00)
Title: Catch JSON load errors

PostgreSQL’s `json` columns do not like malformed JSON values. If we want to be able to catch malformed JSON errors, we need to do it before validation occurs, since setting a malformed JSON value will raise an exception as soon as we set it.

Using the pretty-much undocumented `setup` method in `ActiveModel::EachValidator`, we’re able to define the setter method and thus overwriting it to catch JSON errors.