Skip to content

Commit 95c8f39

Browse files
authored
Use Inferno Validator Public Functions only (#27)
* Use Inferno Validator Public Functions only * Use DSL * Rubocop issues
1 parent 2ec9c78 commit 95c8f39

1 file changed

Lines changed: 9 additions & 16 deletions

File tree

lib/davinci_plan_net_test_kit/reference_resolution_test.rb

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -159,22 +159,15 @@ def validate_reference_resolution(resource, reference, target_profile)
159159
def resource_is_valid_with_target_profile?(resource, target_profile)
160160
return true if target_profile.blank?
161161

162-
# Only need to know if the resource is valid.
163-
# Calling resource_is_valid? causes validation errors to be logged.
164-
validator = find_validator(:default)
165-
166-
target_profile_with_version = target_profile.include?('|') ? target_profile : "#{target_profile}|#{metadata.profile_version}"
167-
168-
validator_response = validator.validate(resource, target_profile_with_version)
169-
outcome = validator.operation_outcome_from_hl7_wrapped_response(validator_response)
170-
171-
message_hashes = outcome.issue&.map { |issue| validator.message_hash_from_issue(issue, resource) } || []
172-
173-
message_hashes.concat(validator.additional_validation_messages(resource, target_profile_with_version))
174-
175-
validator.filter_messages(message_hashes)
176-
177-
message_hashes.none? { |message_hash| message_hash[:type] == 'error' }
162+
target_profile_with_version = target_profile.include?('|') ? target_profile : "#{target_profile}|#{metadata.profile_version}"
163+
164+
# Use the DSL's resource_is_valid? method with add_messages_to_runnable: false
165+
# to validate silently without adding messages to the test output
166+
resource_is_valid?(
167+
resource:,
168+
profile_url: target_profile_with_version,
169+
add_messages_to_runnable: false
170+
)
178171
end
179172
end
180173
end

0 commit comments

Comments
 (0)