Class FHIRValidator


  • @NotThreadSafe
    public class FHIRValidator
    extends java.lang.Object
    A validator that uses conformance resources from the FHIRRegistry to validate resource instances against the base specification and, optionally, extended profiles. The static factory method validator() is threadsafe, but the created instances are not.
    • Field Detail

      • SOURCE_VALIDATOR

        public static final java.lang.String SOURCE_VALIDATOR
        See Also:
        Constant Field Values
    • Method Detail

      • isFailFast

        public boolean isFailFast()
        Indicates whether this validator is fail-fast

        A fail-fast validator is one that terminates on the first issue it finds with a severity of ERROR.

        Returns:
        true if this validator is fail-fast, false otherwise
      • validate

        public java.util.List<OperationOutcome.Issue> validate​(Resource resource,
                                                               java.lang.String... profiles)
                                                        throws FHIRValidationException
        Validate a Resource against constraints in the base specification and resource-asserted profile references or specific profile references but not both.

        Resource-asserted profile references that are not available in the FHIRRegistry result in issues with severity WARNING.

        Unknown profile references passed as arguments to this method result in issues with severity ERROR.

        Profiles that are incompatible with the resource type being validated result in issues with severity ERROR.

        Profile references that are passed into this method are only applicable to the outermost resource (not contained resources).

        Parameters:
        resource - a Resource instance (the target of validation)
        profiles - specific profile references to validate the resource against
        Returns:
        a non-null, possibly empty list of issues generated during validation (sorted by severity)
        Throws:
        FHIRValidationException - for errors that occur during validation
      • validate

        public java.util.List<OperationOutcome.Issue> validate​(Resource resource,
                                                               boolean includeResourceAssertedProfiles,
                                                               java.lang.String... profiles)
                                                        throws FHIRValidationException
        Validate a Resource against constraints in the base specification and resource-asserted profile references and/or specific profile references.

        Resource-asserted profile references that are not available in the FHIRRegistry result in issues with severity WARNING.

        Unknown profile references passed as arguments to this method result in issues with severity ERROR.

        Profiles that are incompatible with the resource type being validated result in issues with severity ERROR.

        Profile references that are passed into this method are only applicable to the outermost resource (not contained resources).

        Parameters:
        resource - a Resource instance (the target of validation)
        includeResourceAssertedProfiles - whether or not to consider resource-asserted profiles during validation
        profiles - specific profile references to validate the resource against
        Returns:
        a non-null, possibly empty list of issues generated during validation (sorted by severity)
        Throws:
        FHIRValidationException - for errors that occur during validation
      • validate

        public java.util.List<OperationOutcome.Issue> validate​(FHIRPathEvaluator.EvaluationContext evaluationContext,
                                                               java.lang.String... profiles)
                                                        throws FHIRValidationException
        Validate a resource, using an FHIRPathEvaluator.EvaluationContext, against constraints in the base specification and resource-asserted profile references or specific profile references but not both.

        Resource-asserted profile references that are not available in the FHIRRegistry result in issues with severity WARNING.

        Unknown profile references passed as arguments to this method result in issues with severity ERROR.

        Profiles that are incompatible with the resource type being validated result in issues with severity ERROR.

        Profile references that are passed into this method are only applicable to the outermost resource (not contained resources).

        Parameters:
        evaluationContext - the FHIRPathEvaluator.EvaluationContext for this validation which includes a FHIRPathTree built from a Resource instance (the target of validation)
        profiles - specific profile references to validate the evaluation context against
        Returns:
        a non-null, possibly empty list of issues generated during validation (sorted by severity)
        Throws:
        FHIRValidationException - for errors that occur during validation
      • validate

        public java.util.List<OperationOutcome.Issue> validate​(FHIRPathEvaluator.EvaluationContext evaluationContext,
                                                               boolean includeResourceAssertedProfiles,
                                                               java.lang.String... profiles)
                                                        throws FHIRValidationException
        Validate a resource, using an FHIRPathEvaluator.EvaluationContext, against constraints in the base specification and resource-asserted profile references and/or specific profile references.

        Resource-asserted profile references that are not available in the FHIRRegistry result in issues with severity WARNING.

        Unknown profile references passed as arguments to this method result in issues with severity ERROR.

        Profiles that are incompatible with the resource type being validated result in issues with severity ERROR.

        Profile references that are passed into this method are only applicable to the outermost resource (not contained resources).

        Parameters:
        evaluationContext - the FHIRPathEvaluator.EvaluationContext for this validation which includes a FHIRPathTree built from a Resource instance (the target of validation)
        includeResourceAssertedProfiles - whether or not to consider resource-asserted profiles during validation
        profiles - specific profile references to validate the evaluation context against
        Returns:
        a non-null, possibly empty list of issues generated during validation (sorted by severity)
        Throws:
        FHIRValidationException - for errors that occur during validation
      • validator

        public static FHIRValidator validator​(boolean failFast)