Sha256: 293ae248f3aad4141abb148d71544f3d558b63b079b12cf7f31e8e7578e693df
Contents?: true
Size: 738 Bytes
Versions: 152
Compression:
Stored size: 738 Bytes
Contents
# frozen_string_literal: true module Playbook module Props class Error < StandardError; end class Base attr_reader :default, :required def initialize(default: nil, required: false) @default = default @required = required end def value(value) value.nil? ? @default : value end def validate!(input_value) raise(Playbook::Props::Error, "#{inspect} is a required prop and needs to be provided a value") if required && input_value.nil? validate(value(input_value)) || raise(Playbook::Props::Error, "Invalid value (#{input_value.inspect}) for prop (#{inspect})") end def validate(_value) true end end end end
Version data entries
152 entries across 152 versions & 1 rubygems