Class: LanggraphPlatform::Utils::Validator
- Inherits:
-
Object
- Object
- LanggraphPlatform::Utils::Validator
- Defined in:
- lib/langgraph_platform/utils/validator.rb
Class Method Summary collapse
- .validate_assistant_id(assistant_id) ⇒ Object
- .validate_cron_schedule(schedule) ⇒ Object
- .validate_enum_values(params, enum_map) ⇒ Object
- .validate_metadata(metadata) ⇒ Object
- .validate_pagination_params(limit, offset) ⇒ Object
- .validate_param_types(params, type_map) ⇒ Object
- .validate_required_params(params, required_keys) ⇒ Object
- .validate_run_id(run_id) ⇒ Object
- .validate_thread_id(thread_id) ⇒ Object
Class Method Details
.validate_assistant_id(assistant_id) ⇒ Object
34 35 36 37 38 |
# File 'lib/langgraph_platform/utils/validator.rb', line 34 def self.validate_assistant_id(assistant_id) return unless assistant_id.nil? || assistant_id.to_s.strip.empty? raise ArgumentError, 'Assistant ID cannot be nil or empty' end |
.validate_cron_schedule(schedule) ⇒ Object
52 53 54 55 56 57 58 59 60 |
# File 'lib/langgraph_platform/utils/validator.rb', line 52 def self.validate_cron_schedule(schedule) raise ArgumentError, 'Cron schedule cannot be nil or empty' if schedule.nil? || schedule.to_s.strip.empty? # Basic cron validation - should have 5 or 6 parts parts = schedule.split(' ') return if [5, 6].include?(parts.length) raise ArgumentError, "Invalid cron schedule format. Expected 5 or 6 parts, got #{parts.length}" end |
.validate_enum_values(params, enum_map) ⇒ Object
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/langgraph_platform/utils/validator.rb', line 23 def self.validate_enum_values(params, enum_map) enum_map.each do |key, allowed_values| value = params[key] next if value.nil? unless allowed_values.include?(value) raise ArgumentError, "Parameter '#{key}' must be one of #{allowed_values.join(', ')}, got '#{value}'" end end end |
.validate_metadata(metadata) ⇒ Object
70 71 72 73 74 |
# File 'lib/langgraph_platform/utils/validator.rb', line 70 def self.() return if .is_a?(Hash) raise ArgumentError, 'Metadata must be a Hash' end |
.validate_pagination_params(limit, offset) ⇒ Object
62 63 64 65 66 67 68 |
# File 'lib/langgraph_platform/utils/validator.rb', line 62 def self.validate_pagination_params(limit, offset) raise ArgumentError, 'Limit must be a positive integer' if limit && (!limit.is_a?(Integer) || limit < 1) return unless offset && (!offset.is_a?(Integer) || offset.negative?) raise ArgumentError, 'Offset must be a non-negative integer' end |
.validate_param_types(params, type_map) ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/langgraph_platform/utils/validator.rb', line 12 def self.validate_param_types(params, type_map) type_map.each do |key, expected_type| value = params[key] next if value.nil? unless value.is_a?(expected_type) raise ArgumentError, "Parameter '#{key}' must be of type #{expected_type}, got #{value.class}" end end end |
.validate_required_params(params, required_keys) ⇒ Object
4 5 6 7 8 9 10 |
# File 'lib/langgraph_platform/utils/validator.rb', line 4 def self.validate_required_params(params, required_keys) missing_keys = required_keys - params.keys return if missing_keys.empty? raise ArgumentError, "Missing required parameters: #{missing_keys.join(', ')}" end |
.validate_run_id(run_id) ⇒ Object
46 47 48 49 50 |
# File 'lib/langgraph_platform/utils/validator.rb', line 46 def self.validate_run_id(run_id) return unless run_id.nil? || run_id.to_s.strip.empty? raise ArgumentError, 'Run ID cannot be nil or empty' end |
.validate_thread_id(thread_id) ⇒ Object
40 41 42 43 44 |
# File 'lib/langgraph_platform/utils/validator.rb', line 40 def self.validate_thread_id(thread_id) return unless thread_id.nil? || thread_id.to_s.strip.empty? raise ArgumentError, 'Thread ID cannot be nil or empty' end |