Sha256: c7f348fb1dafe3a1d40df00a22b0638da4f569b456229587abd17d1f9c69bf5a

Contents?: true

Size: 690 Bytes

Versions: 6

Compression:

Stored size: 690 Bytes

Contents

module {{namespace_module}}
  module {{resource_module}}
    module Show
      class Validator
        include Shogun::Validator
        include {{resource_module}}

        ID_MATCH = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/
        FIELDS_ALLOWED = %w|id created_at updated_at destroyed_at href|

        def initialize(data:)
          @verifiers = [
            Shogun::Verifier::Presence.new(data: data.id, name: "id"),
            Shogun::Verifier::Match.new(data: data.id, name: "id", comparison: ID_MATCH),
            Shogun::Verifier::Allowed.new(data: data.fields, name: "fields", list: FIELDS_ALLOWED)
          ]
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
shogun-6.4.2 scaffold/generate/resource/show/validator.rb
shogun-6.4.1 scaffold/generate/resource/show/validator.rb
shogun-6.4.0 scaffold/generate/resource/show/validator.rb
shogun-6.3.0 scaffold/generate/resource/show/validator.rb
shogun-6.2.3 scaffold/generate/resource/show/validator.rb
shogun-6.2.2 scaffold/generate/resource/show/validator.rb