Stream: dotnet
Topic: Simple question about Validator
Yunwei Wang (Jan 10 2018 at 22:15):
This is the first time I try to use Validator class to do a client side validation. My use case is very simple. I need to validate a ValueSet resource using base profile in a integration test. Here is the code section:
var validator = new Validator(); var outcome = validator.Validate(vs);
where vs is the ValueSet instance.
The outcome shows failed. The message is
{Text="Unable to resolve reference to profile 'http://hl7.org/fhir/StructureDefinition/ValueSet'"}
Did I miss something?
Yunwei Wang (Jan 10 2018 at 22:37):
Ah. Figured out. I need to add definition zip into the Validator.
var setting = new ValidationSettings { ResourceResolver = new ZipSource("definitions.xml.zip") }; var validator = new Validator(setting); var outcome = validator.Validate(vs);
Ewout Kramer (Jan 11 2018 at 09:07):
I am sorry about that, but yes. This used to be an out-of-the-box experience, but the new NuGet will install dependencies (specification.zip) in the global NuGet cache - and although the project correctly references it, it won't be copied into the /bin directory of your application - and the validator won't find it unless you explicitly copy it into your project and reference it (as you do here). By the way definition.xml.zip is fine, but the specification.zip that's in the distribution might even be better - we do technical corrections on the fhirpath statements - which won't be in the definition.xml.zip on the fhir website.
Yunwei Wang (Jan 11 2018 at 15:56):
@Ewout Kramer Where can I download specification.zip? I don't see it on the fhir download page (http://build.fhir.org/downloads.html)
Michel Rutten (Jan 11 2018 at 15:58):
The specification.zip file is included in the Hl7.Fhir.STU3.Specification library NuGet package. However as Ewout mentions, NuGet now installs this dependency in the global NuGet cache. For example:
%UserProfile%\.nuget\packages\hl7.fhir.specification.stu3\0.94.0-beta2\contentFiles\any\any
Ewout Kramer (Jan 11 2018 at 17:31):
Yes, a bit hard.... I'll try to find a better answer next week...
Last updated: Apr 12 2022 at 19:14 UTC