Sha256: 9ec479e7cf3bc4d1dba3086cabdac79212b684da154b683adf0a6b18128e9ddc
Contents?: true
Size: 736 Bytes
Versions: 3
Compression:
Stored size: 736 Bytes
Contents
module DataModel # acts as any type, the only way to fail validation is if it is nil and not present class Builtin::Object < Type include Errors # Object arguments class Arguments < Struct # @!attribute optional # @return [Boolean] whether or not this type is optional prop :optional, :boolean, default: false end # read a value, and validate it # @param val [Object] the value to read # @param coerce [Boolean] whether to coerce the value # @return [Array(Object, Error)] the result of reading the value def read(val, coerce: false) args = Arguments.new(type_args) err = Error.new if val.nil? && !args.optional err.add(missing_error(type_name)) end return [val, err] end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
data_model-0.6.1 | lib/data_model/builtin/object.rb |
data_model-0.6.0 | lib/data_model/builtin/object.rb |
data_model-0.5.0 | lib/data_model/builtin/object.rb |