app/models/concerns/fields_validator.rb
def validate_each(record, attribute, value)
    validates_uniqueness_of_slugs(record, attribute, value)
    validates_fields_do_not_conflict_with_reserved_names(record, attribute, value)

    value.each do |field|
      record.errors[:base] << 'Fields must have a name.' unless field[:name].present?
      record.errors[:base] << 'Invalid field type.' unless VALID_FIELD_TYPES.include? field[:type]
      record.errors[:base] << 'Invalid field name.' unless field[:slug].match /\A(?:[a-z0-9]+_?)*[a-z0-9]+\z/
      record.errors[:base] << 'Field name cannot contain only numbers.' if field[:slug].match /\A\d+\Z/
    end
  end
# Maybe rename to ContentModelValidator for consistency.
Maybe rename to ContentModelValidator for consistency.
Maybe rename to ContentModelValidator for consistency .
def validate_each(record, attribute, value)
    validates_uniqueness_of_slugs(record, attribute, value)
    validates_fields_do_not_conflict_with_reserved_names(record, attribute, value)
    value.each do |field|
      record.errors[:base] << 'Fields must have a name.' unless field[:name].present?
      record.errors[:base] << 'Invalid field type.' unless VALID_FIELD_TYPES.include? field[:type]
      record.errors[:base] << 'Invalid field name.' unless field[:slug].match /\A(?:[a-z0-9]+_?)*[a-z0-9]+\z/
      record.errors[:base] << 'Field name cannot contain only numbers.' if field[:slug].match /\A\d+\Z/
    end
  end
def validate_each ( record , attribute , value ) validates_uniqueness_of_slugs ( record , attribute , value ) validates_fields_do_not_conflict_with_reserved_names ( record , attribute , value ) value . each do | field | record . errors [ :base ] << 'Fields must have a name.' unless field [ :name ] . present? record . errors [ :base ] << 'Invalid field type.' unless VALID_FIELD_TYPES . include? field [ :type ] record . errors [ :base ] << 'Invalid field name.' unless field [ :slug ] . match / \A (?:[a-z0-9]+_?)*[a-z0-9]+ \z / record . errors [ :base ] << 'Field name cannot contain only numbers.' if field [ :slug ] . match / \A \d + \Z / end end
Maybe rename to ContentModelValidator for consistency.
Maybe rename to ContentModelValidator for consistency .
record
attribute
value