Sha256: 2287bf7e5db41b8b8b5707f78c9506384d9bb3d50e28b37b15ba87bc7725e5a3
Contents?: true
Size: 754 Bytes
Versions: 2
Compression:
Stored size: 754 Bytes
Contents
# frozen_string_literal: true 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', __dir__) 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
arbetsformedlingen-0.7.0 | lib/arbetsformedlingen/models/document.rb |
arbetsformedlingen-0.6.0 | lib/arbetsformedlingen/models/document.rb |