Sha256: 287ec17c197adf626a7c86d8d514672128d62835f3033b07e5cce0f16801e6b7
Contents?: true
Size: 726 Bytes
Versions: 2
Compression:
Stored size: 726 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 || @default 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
playbook_ui-2.9.4 | app/pb_kits/playbook/props/base.rb |
playbook_ui-2.9.3 | app/pb_kits/playbook/props/base.rb |