Package ca.uhn.fhir.validation
Class FhirValidator
- java.lang.Object
-
- ca.uhn.fhir.validation.FhirValidator
-
public class FhirValidator extends Object
Resource validator, which checks resources for compliance against various validation schemes (schemas, schematrons, profiles, etc.)To obtain a resource validator, call
FhirContext.newValidator()Thread safety note: This class is thread safe, so you may register or unregister validator modules at any time. Individual modules are not guaranteed to be thread safe however. Reconfigure them with caution.
-
-
Constructor Summary
Constructors Constructor Description FhirValidator(FhirContext theFhirContext)Constructor (this should not be called directly, but ratherFhirContext.newValidator()should be called to obtain an instance ofFhirValidator)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanisValidateAgainstStandardSchema()Should the validator validate the resource against the base schema (the schema provided with the FHIR distribution itself)booleanisValidateAgainstStandardSchematron()Should the validator validate the resource against the base schema (the schema provided with the FHIR distribution itself)FhirValidatorregisterValidatorModule(IValidatorModule theValidator)Add a new validator module to this validator.FhirValidatorsetValidateAgainstStandardSchema(boolean theValidateAgainstStandardSchema)Should the validator validate the resource against the base schema (the schema provided with the FHIR distribution itself)FhirValidatorsetValidateAgainstStandardSchematron(boolean theValidateAgainstStandardSchematron)Should the validator validate the resource against the base schematron (the schematron provided with the FHIR distribution itself)voidunregisterValidatorModule(IValidatorModule theValidator)Removes a validator module from this validator.ValidationResultvalidateWithResult(String theResource)Validates a resource instance returning aValidationResultwhich contains the results.ValidationResultvalidateWithResult(String theResource, ValidationOptions theOptions)Validates a resource instance returning aValidationResultwhich contains the results.ValidationResultvalidateWithResult(IBaseResource theResource)Validates a resource instance returning aValidationResultwhich contains the results.ValidationResultvalidateWithResult(IBaseResource theResource, ValidationOptions theOptions)Validates a resource instance returning aValidationResultwhich contains the results.
-
-
-
Constructor Detail
-
FhirValidator
public FhirValidator(FhirContext theFhirContext)
Constructor (this should not be called directly, but ratherFhirContext.newValidator()should be called to obtain an instance ofFhirValidator)
-
-
Method Detail
-
isValidateAgainstStandardSchema
public boolean isValidateAgainstStandardSchema()
Should the validator validate the resource against the base schema (the schema provided with the FHIR distribution itself)
-
isValidateAgainstStandardSchematron
public boolean isValidateAgainstStandardSchematron()
Should the validator validate the resource against the base schema (the schema provided with the FHIR distribution itself)
-
registerValidatorModule
public FhirValidator registerValidatorModule(IValidatorModule theValidator)
Add a new validator module to this validator. You may register as many modules as you like at any time.- Parameters:
theValidator- The validator module. Must not be null.- Returns:
- Returns a reference to
thisfor easy method chaining.
-
setValidateAgainstStandardSchema
public FhirValidator setValidateAgainstStandardSchema(boolean theValidateAgainstStandardSchema)
Should the validator validate the resource against the base schema (the schema provided with the FHIR distribution itself)- Returns:
- Returns a referens to
thisfor method chaining
-
setValidateAgainstStandardSchematron
public FhirValidator setValidateAgainstStandardSchematron(boolean theValidateAgainstStandardSchematron)
Should the validator validate the resource against the base schematron (the schematron provided with the FHIR distribution itself)- Returns:
- Returns a referens to
thisfor method chaining
-
unregisterValidatorModule
public void unregisterValidatorModule(IValidatorModule theValidator)
Removes a validator module from this validator. You may register as many modules as you like, and remove them at any time.- Parameters:
theValidator- The validator module. Must not be null.
-
validateWithResult
public ValidationResult validateWithResult(IBaseResource theResource)
Validates a resource instance returning aValidationResultwhich contains the results.- Parameters:
theResource- the resource to validate- Returns:
- the results of validation
- Since:
- 0.7
-
validateWithResult
public ValidationResult validateWithResult(String theResource)
Validates a resource instance returning aValidationResultwhich contains the results.- Parameters:
theResource- the resource to validate- Returns:
- the results of validation
- Since:
- 1.1
-
validateWithResult
public ValidationResult validateWithResult(IBaseResource theResource, ValidationOptions theOptions)
Validates a resource instance returning aValidationResultwhich contains the results.- Parameters:
theResource- the resource to validatetheOptions- Optionally provides options to the validator- Returns:
- the results of validation
- Since:
- 4.0.0
-
validateWithResult
public ValidationResult validateWithResult(String theResource, ValidationOptions theOptions)
Validates a resource instance returning aValidationResultwhich contains the results.- Parameters:
theResource- the resource to validatetheOptions- Optionally provides options to the validator- Returns:
- the results of validation
- Since:
- 4.0.0
-
-