Sha256: 5cc008b11c62e7337aba105732d78864e71f090d4ab9d0d6727b059ce7048bcd
Contents?: true
Size: 724 Bytes
Versions: 7
Compression:
Stored size: 724 Bytes
Contents
require 'securerandom' module Arbetsformedlingen DocumentSchema = Dry::Validation.Form do configure do config.type_specs = true config.messages_file = File.expand_path('../../../../config/locales/errors.yml', __FILE__) predicates(Predicates) end required(:id, Types::UUIDString).filled required(:timestamp, :string).filled(:iso8601_date?) required(:customer_id, Types::StrippedString).filled required(:email, Types::StrippedString).filled(:str?, :email?) end class Document < Model def initialize(hash) data = { id: SecureRandom.uuid, timestamp: Time.now.utc.iso8601 }.merge!(hash) super(DocumentSchema.call(data)) end end end
Version data entries
7 entries across 7 versions & 1 rubygems