Module: Inferno::DSL::FHIRResourceValidation::ClassMethods

Defined in:
lib/inferno/dsl/fhir_resource_validation.rb

Instance Method Summary collapse

Instance Method Details

#fhir_resource_validator(name = :default, required_suite_options: nil, &block) ⇒ Object

Define a validator

Examples:

fhir_resource_validator do
  url 'http://example.com/validator'
  exclude_message { |message| message.type == 'info' }
  perform_additional_validation do |resource, profile_url|
    if something_is_wrong
      { type: 'error', message: 'something is wrong' }
    else
      { type: 'info', message: 'everything is ok' }
    end
  end
end

Parameters:

  • name (Symbol) (defaults to: :default)

    the name of the validator, only needed if you are using multiple validators

  • required_suite_options (Hash) (defaults to: nil)

    suite options that must be selected in order to use this validator



367
368
369
370
371
372
373
374
375
376
# File 'lib/inferno/dsl/fhir_resource_validation.rb', line 367

def fhir_resource_validator(name = :default, required_suite_options: nil, &block)
  current_validators = fhir_validators[name] || []

  new_validator = Inferno::DSL::FHIRResourceValidation::Validator.new(name, id, required_suite_options, &block)

  current_validators.reject! { |validator| validator.requirements == required_suite_options }
  current_validators << new_validator

  fhir_validators[name] = current_validators
end