Sha256: d1748a52185c72c9356a5b646fafebe689683c73b677ee0b02a0fc9e5f39625e
Contents?: true
Size: 596 Bytes
Versions: 2
Compression:
Stored size: 596 Bytes
Contents
class Taro::Types::Scalar::ISO8601DateType < Taro::Types::ScalarType self.desc = 'Represents a time as Date in ISO8601 format.' self.openapi_type = :string PATTERN = /\A\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])\z/ def coerce_input if object.instance_of?(String) && object.match?(PATTERN) Date.parse(object) else input_error("must be a ISO8601 formatted string") end end def coerce_response case object when Date, DateTime, Time object.strftime("%Y-%m-%d") else response_error("must be a Time, Date, or DateTime") end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
taro-1.1.0 | lib/taro/types/scalar/iso8601_date_type.rb |
taro-1.0.0 | lib/taro/types/scalar/iso8601_date_type.rb |