Sha256: 75a1d26edb0164c83ad71565ffe7426ac1181718deb389954ee2d9eac73d797a
Contents?: true
Size: 1.07 KB
Versions: 9
Compression:
Stored size: 1.07 KB
Contents
# frozen_string_literal: true require 'luna_park/validators/dry' require 'cyclone_lariat/errors' module CycloneLariat module Messages module V1 class Validator < LunaPark::Validators::Dry UUID_MATCHER = /^\h{8}-\h{4}-(\h{4})-\h{4}-\h{12}$/.freeze ISO8601_MATCHER = /^(-?(?:[1-9][0-9]*)?[0-9]{4})-(1[0-2]|0[1-9])-(3[0-1]|0[1-9]|[1-2][0-9])T(2[0-3]|[0-1][0-9]):([0-5][0-9]):([0-5][0-9])(\.[0-9]+)?(Z|[+-](?:2[0-3]|[0-1][0-9]):[0-5][0-9])?$/.freeze validation_schema do params do required(:uuid).value(format?: UUID_MATCHER) required(:publisher).filled(:string) required(:type).filled(:string) required(:version).filled(:integer).value(eql?: 1) required(:data).value(:hash?) optional(:request_id).value(format?: UUID_MATCHER) required(:sent_at).value(format?: ISO8601_MATCHER) end end def check! raise Errors::InvalidMessage.new(message: params, validation_errors: errors) unless success? end end end end end
Version data entries
9 entries across 9 versions & 1 rubygems