Module: Olyx::Guardrails::PolicyRuleComponents::NameValue
- Defined in:
- lib/olyx/guardrails/policy_rule/name_value.rb
Overview
Validates and freezes a policy-rule identifier.
Constant Summary collapse
- FORMAT =
/\A[a-z][a-z0-9_.:-]*\z/i
Class Method Summary collapse
Class Method Details
.call(value) ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/olyx/guardrails/policy_rule/name_value.rb', line 12 def call(value) normalized = value.to_s valid = (value.is_a?(String) || value.is_a?(Symbol)) && normalized.match?(FORMAT) raise ArgumentError, 'policy rule name must be a String or Symbol identifier' unless valid normalized.dup.freeze end |