Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,30 @@ def execute
flow: flow.id,
data_type_identifier: data_type_identifier.id,
errors: data_type_identifier.errors.full_messages)
errors << ValidationResult.error(:data_type_identifier_model_invalid, data_type_identifier.errors)
errors << ValidationResult.error(
:data_type_identifier_model_invalid,
details: data_type_identifier.errors,
location: data_type_identifier
)
end
if data_type_identifier.runtime != flow.project.primary_runtime
logger.debug(message: 'Data type identifier runtime mismatch',
primary_runtime: flow.project.primary_runtime.id,
given_runtime: data_type_identifier.runtime.id,
flow: flow.id,
data_type_identifier: data_type_identifier.id)
errors << ValidationResult.error(:data_type_identifier_runtime_mismatch)
errors << ValidationResult.error(
:data_type_identifier_runtime_mismatch,
location: data_type_identifier
)
end

if data_type_identifier.generic_key.present?
unless node.runtime_function.generic_keys.include?(data_type_identifier.generic_key)
errors << ValidationResult.error(:data_type_identifier_generic_key_not_found)
errors << ValidationResult.error(
:data_type_identifier_generic_key_not_found,
location: data_type_identifier
)
end
elsif data_type_identifier.generic_type.present?
errors += ::NodeFunction::GenericTypeValidationService.new(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ def execute
data_type: data_type.id,
rule: rule.id,
errors: rule.errors.full_messages)
errors << ValidationResult.error(:data_type_rule_model_invalid, rule.errors)
errors << ValidationResult.error(
:data_type_rule_model_invalid,
details: rule.errors,
location: rule
)
end
end
errors
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ def execute
flow: flow.id,
data_type: data_type.id,
errors: data_type.errors.full_messages)
errors << ValidationResult.error(:data_type_model_invalid, data_type.errors)
errors << ValidationResult.error(
:data_type_model_invalid,
details: data_type.errors,
location: data_type
)
end

primary_runtime = flow.project.primary_runtime
Expand All @@ -38,7 +42,10 @@ def execute
given_runtime: data_type.runtime.id,
flow: flow.id,
data_type: data_type.id)
errors << ValidationResult.error(:data_type_runtime_mismatch)
errors << ValidationResult.error(
:data_type_runtime_mismatch,
location: data_type
)
end

data_type.parent_type&.tap do |parent_type|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ def execute

if setting.invalid?
logger.debug("Invalid setting: #{setting.errors.full_messages.join(', ')}")
errors << ValidationResult.error(:flow_setting_model_invalid, setting.errors)
errors << ValidationResult.error(
:flow_setting_model_invalid,
details: setting.errors,
location: setting
)
end
errors
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ def execute
logger.debug("Validating flow_type: #{flow_type.inspect} for flow: #{flow.id}")

if flow_type.runtime != flow.project.primary_runtime
errors << ValidationResult.error(:flow_type_runtime_mismatch)
errors << ValidationResult.error(
:flow_type_runtime_mismatch,
location: flow_type
)
end
errors
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ def execute

# Validate the target the identifier gets validated later
unless parameter.node_function.runtime_function.generic_keys.include?(target)
errors << ValidationResult.error(:generic_key_not_found)
errors << ValidationResult.error(
:generic_key_not_found,
location: generic_mapper
)
end

generic_mapper.generic_combination_strategies.each do |_strategy|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,17 @@ def execute
if parameter.invalid?
logger.debug(message: 'Node parameter validation failed',
errors: parameter.errors.full_messages)
errors << ValidationResult.error(:node_parameter_model_invalid, parameter.errors)
errors << ValidationResult.error(
:node_parameter_model_invalid,
details: parameter.errors,
location: parameter
)
end
if parameter.runtime_parameter.runtime_function_definition.runtime != flow.project.primary_runtime
errors << ValidationResult.error(:node_parameter_runtime_mismatch)
errors << ValidationResult.error(
:node_parameter_runtime_mismatch,
location: parameter
)
end

if parameter.literal_value.present?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,27 @@ def execute
if node_function.invalid?
logger.debug(message: 'Node function validation failed',
errors: node_function.errors.full_messages)
errors << ValidationResult.error(:node_function_model_invalid, node_function.errors)
errors << ValidationResult.error(
:node_function_model_invalid,
details: node_function.errors,
location: node_function
)
end
if node_function.runtime_function.runtime != flow.project.primary_runtime
errors << ValidationResult.error(:node_function_runtime_mismatch)
errors << ValidationResult.error(
:node_function_runtime_mismatch,
location: node_function
)
end

node_function.runtime_function.tap do |runtime_function|
logger
.debug("Validating runtime function: #{runtime_function.id} for node function: #{node_function.id}")
if runtime_function.runtime != flow.project.primary_runtime
errors << ValidationResult.error(:node_function_runtime_mismatch)
errors << ValidationResult.error(
:node_function_runtime_mismatch,
location: node_function
)
end
end

Expand All @@ -46,7 +56,10 @@ def execute
node_function: node_function.id,
runtime_parameter: parameter.runtime_parameter.id,
flow: flow.id)
errors << ValidationResult.error(:parameter_mismatch)
errors << ValidationResult.error(
:parameter_mismatch,
location: parameter
)
end

errors += NodeFunctionParameterValidationService.new(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ def execute
errors = []

unless reference_value.valid?
errors << ValidationResult.error(:reference_value_invalid, reference_value.errors)
errors << ValidationResult.error(
:reference_value_invalid,
details: reference_value.errors,
location: reference_value
)
end

# https://github.com/code0-tech/sagittarius/issues/508 Validate the usage and datatypes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,31 @@ module Projects
module Flows
module Validation
class ValidationResult
def self.typo(error_code, details = nil)
new(severity: :typo, error_code: error_code, details: details)
def self.typo(error_code, location:, details: nil)
new(severity: :typo, error_code: error_code, details: details, location: location)
end

def self.error(error_code, details = nil)
new(severity: :error, error_code: error_code, details: details)
def self.error(error_code, location:, details: nil)
new(severity: :error, error_code: error_code, details: details, location: location)
end

def self.weak(error_code, details = nil)
new(severity: :weak, error_code: error_code, details: details)
def self.weak(error_code, location:, details: nil)
new(severity: :weak, error_code: error_code, details: details, location: location)
end

def self.warning(error_code, details = nil)
new(severity: :warning, error_code: error_code, details: details)
def self.warning(error_code, location:, details: nil)
new(severity: :warning, error_code: error_code, details: details, location: location)
end

attr_reader :severity, :error_code, :details
attr_reader :severity, :error_code, :details, :location

def initialize(severity:, error_code:, details:)
def initialize(severity:, error_code:, details:, location:)
FlowValidationErrorCode.validate_error_code!(error_code)

@severity = severity
@error_code = error_code
@details = details
@location = location
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@ def execute
errors = []

primary_runtime = flow.project.primary_runtime
errors << ValidationResult.error(:no_primary_runtime) if primary_runtime.nil?
if primary_runtime.nil?
errors << ValidationResult.error(
:no_primary_runtime,
location: flow.project
)
end

# ---
# Input Type Validation
Expand Down