lib/avromatic/model/attributes.rb in avromatic-0.9.0.rc6 vs lib/avromatic/model/attributes.rb in avromatic-0.9.0.rc7
- old
+ new
@@ -75,25 +75,14 @@
when :enum
validates(field.name,
inclusion: { in: Set.new(field.type.symbols.map(&:freeze)).freeze })
when :fixed
validates(field.name, length: { is: field.type.size })
- when :record
- validate_record(field.name)
+ when :record, :array, :map, :union
+ validate_complex(field.name)
end
add_required_validation(field)
- end
-
- def validate_record(field_name)
- validate do |instance|
- record = instance.send(field_name)
- if record && record.invalid?
- record.errors.each do |key, message|
- errors.add(field_name.to_sym, "invalid: #{key} #{message}")
- end
- end
- end
end
def add_required_validation(field)
if required?(field) && field.default == :no_default
case field.type.type_sym