module JsonbAccessor::QueryHelper
def validate_field_name!(query, column_name, field_name)
def validate_field_name!(query, column_name, field_name) store_keys = query.model.public_send("jsonb_store_key_mapping_for_#{column_name}").values if store_keys.exclude?(field_name.to_s) valid_field_names = store_keys.map { |key| "`#{key}`" }.join(", ") raise InvalidFieldName, "`#{field_name}` is not a valid field name, valid field names include: #{valid_field_names}" end end