Validate FHIR R4, R4B, and R5 resources against StructureDefinitions, profiles, and terminology
with a fast, embeddable Go library and CLI tool.
All validation rules derived from StructureDefinitions. No hardcoded logic — supports any FHIR profile or Implementation Guide.
Designed to produce the same validation results as the HL7 FHIR Validator, with significantly faster startup and lower memory usage.
Full FHIRPath evaluation engine for invariant constraints defined in ElementDefinitions, including resolve() and memberOf().
Install the validator:
go get github.com/gofhir/validatorValidate a FHIR resource:
package main
import (
"fmt"
"github.com/gofhir/validator"
)
func main() {
v := validator.New()
result := v.ValidateFile("patient.json")
for _, issue := range result.Issues() {
fmt.Printf("[%s] %s: %s\n", issue.Severity, issue.Expression, issue.Diagnostics)
}
}Or use the CLI:
gofhir-validator patient.json