You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Since attribute setter got JSON parsing error, it replaces it with empty object {} which is passed then to validate_each, and if schema supports empty object, validation is passed and no error is added even if "#{attribute}_invalid_json" is not empty.
It seems it is needed to add in the beginning of validate_each method something like:
return record.errors.add(attribute, 'JSON parse error') if record.send(:"#{attribute}_invalid_json").present?
The text was updated successfully, but these errors were encountered:
Env: ruby 2.7.1, Rails 6.0.3.2
Modified given example as follows:
Schema (added empty object):
Model (removed 'profile' presence validation):
Expected result:
Observed result:
Since attribute setter got JSON parsing error, it replaces it with empty object
{}
which is passed then to validate_each, and if schema supports empty object, validation is passed and no error is added even if"#{attribute}_invalid_json"
is not empty.It seems it is needed to add in the beginning of
validate_each
method something like:The text was updated successfully, but these errors were encountered: