Sha256: 772ae47757d16e104382a807d9df21d717c27622ba21d5f82c5dedc953c58270
Contents?: true
Size: 579 Bytes
Versions: 10
Compression:
Stored size: 579 Bytes
Contents
# frozen_string_literal: true module Avromatic module Model module FieldHelper extend self # An optional field is represented as a union where the first member # is null. def optional?(field) field.type.type_sym == :union && field.type.schemas.first.type_sym == :null end def required?(field) !optional?(field) end def boolean?(field) field.type.type_sym == :boolean || (FieldHelper.optional?(field) && field.type.schemas.last.type_sym == :boolean) end end end end
Version data entries
10 entries across 10 versions & 1 rubygems