lib/mongoff/validator.rb
# Validation Keywords for Any Instance Type
Validation Keywords for Any Instance Type
Validation Keywords for Any Instance Type
def check_type(type, instance, _, _, options)
      return if instance.nil? && options[:skip_nulls]
      type =
        if (instance.is_a?(Mongoff::Record) || instance.is_a?(Mongoff::RecordArray)) && instance.orm_model.modelable?
          if type == 'object'
            :record
          else
            :record_array
          end
        else
          type && type.to_sym
        end
      if type
        raise "of type #{instance.class} is not an instance for type #{type}" unless instance.is_a?(TYPE_MAP[type])
      else
        raise "of type #{instance.class} is not a valid JSON type" unless Cenit::Utility.json_object?(instance)
      end
    end
def check_type ( type , instance , _ , _ , options ) return if instance . nil? && options [ :skip_nulls ] type = if ( instance . is_a? ( Mongoff :: Record ) || instance . is_a? ( Mongoff :: RecordArray ) ) && instance . orm_model . modelable? if type == 'object' :record else :record_array end else type && type . to_sym end if type raise "of type #{instance.class} is not an instance for type #{type}" unless instance . is_a? ( TYPE_MAP [ type ] ) else raise "of type #{instance.class} is not a valid JSON type" unless Cenit :: Utility . json_object? ( instance ) end end
Validation Keywords for Any Instance Type
Validation Keywords for Any Instance Type
type
<not_specific>
instance
<not_specific>
_
<not_specific>
options
<not_specific>