Class: Temporalio::Worker::IllegalWorkflowCallValidator
- Inherits:
-
Object
- Object
- Temporalio::Worker::IllegalWorkflowCallValidator
- Defined in:
- lib/temporalio/worker/illegal_workflow_call_validator.rb
Overview
Custom validator for validating illegal workflow calls.
Defined Under Namespace
Classes: CallInfo
Instance Attribute Summary collapse
-
#block ⇒ Proc
readonly
Block provided in constructor to invoke.
-
#method_name ⇒ String?
readonly
Method name if this validator is specific to a method.
Class Method Summary collapse
-
.default_time_validators ⇒ Array<IllegalWorkflowCallValidator>
Set of advanced validators for Time calls.
Instance Method Summary collapse
-
#initialize(method_name: nil) {|info| ... } ⇒ IllegalWorkflowCallValidator
constructor
Create a call validator.
Constructor Details
#initialize(method_name: nil) {|info| ... } ⇒ IllegalWorkflowCallValidator
Create a call validator.
55 56 57 58 59 60 61 |
# File 'lib/temporalio/worker/illegal_workflow_call_validator.rb', line 55 def initialize(method_name: nil, &block) raise 'Block required' unless block_given? raise TypeError, 'Method name must be Symbol' unless method_name.nil? || method_name.is_a?(Symbol) @method_name = method_name @block = block end |
Instance Attribute Details
#block ⇒ Proc (readonly)
Returns Block provided in constructor to invoke. See constructor for more details.
46 47 48 |
# File 'lib/temporalio/worker/illegal_workflow_call_validator.rb', line 46 def block @block end |
#method_name ⇒ String? (readonly)
Returns Method name if this validator is specific to a method.
43 44 45 |
# File 'lib/temporalio/worker/illegal_workflow_call_validator.rb', line 43 def method_name @method_name end |
Class Method Details
.default_time_validators ⇒ Array<IllegalWorkflowCallValidator>
Returns Set of advanced validators for Time calls.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/temporalio/worker/illegal_workflow_call_validator.rb', line 24 def self.default_time_validators @default_time_validators ||= [ # Do not consider initialize as invalid if year is present and not "true" IllegalWorkflowCallValidator.new(method_name: :initialize) do |info| year_val = info.trace_point.binding&.local_variable_get(:year) raise 'can only use if passing string or explicit time info' unless year_val && year_val != true end, IllegalWorkflowCallValidator.new(method_name: :now) do # When the xmlschema (aliased as iso8601) call is made, zone_offset is called which has a default parameter # of Time.now.year. We want to prevent failing in that specific case. It is expensive to access the caller # stack, but this is only done in the rare case they are calling this safely. next if caller_locations&.any? { |loc| loc.label == 'zone_offset' || loc.label == 'Time.zone_offset' } raise 'Invalid Time.now call' end ] end |