Module: ActiveJob::Temporal::WorkflowIdentity

Extended by:
ActiveSupport::Concern
Defined in:
lib/activejob/temporal/workflow_identity.rb

Constant Summary collapse

UNSET =
Object.new.freeze
CONTROL_CHARACTER_PATTERN =
/[[:cntrl:]]/

Class Method Summary collapse

Class Method Details

.normalize_identity_value(value, label) ⇒ Object

Raises:

  • (ArgumentError)


14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/activejob/temporal/workflow_identity.rb', line 14

def self.normalize_identity_value(value, label)
  raise ArgumentError, "#{label} must be a String" unless value.is_a?(String)

  normalized = value.strip
  raise ArgumentError, "#{label} must be present" if normalized.empty?
  raise ArgumentError, "#{label} must be valid UTF-8" unless normalized.valid_encoding?

  if normalized.match?(CONTROL_CHARACTER_PATTERN)
    raise ArgumentError, "#{label} cannot contain control characters"
  end

  normalized
end