Sha256: bdd354c8c58661bb65e81283fbfd045fc655aee5600dbb19cd6fc0a4c54fde81
Contents?: true
Size: 726 Bytes
Versions: 1
Compression:
Stored size: 726 Bytes
Contents
require 'securerandom' module Arbetsformedlingen DocumentSchema = Dry::Validation.Params 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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
arbetsformedlingen-0.5.0 | lib/arbetsformedlingen/models/document.rb |