-
Notifications
You must be signed in to change notification settings - Fork 67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Personal/rogrdon/create common validation logic #152
Personal/rogrdon/create common validation logic #152
Conversation
src/lib/Microsoft.Health.Fhir.Ingest.Validation/IIotConnectorValidator.cs
Outdated
Show resolved
Hide resolved
{ | ||
if (string.IsNullOrWhiteSpace(deviceMappingContent) && string.IsNullOrWhiteSpace(fhirMappingContent)) | ||
{ | ||
throw new ArgumentException($"At least one of [{nameof(deviceMappingContent)}] or [{nameof(fhirMappingContent)}] must be provided"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we just return a ValidationResult here? I think It would be useful if this interface could be relied on to always return a Validation result so the consumer wouldn't need to wrap this in a Try/Catch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had debated about that. I leaned towards this not actually being a validation error, but an actual error with the use of the class and its arguments. We are still verifying arguments here so validation hasn't really begun. It felt strange to add such an error inside of the ValidationResult.
That's just my opinion though. I can merge what I have and change it in a subsequent PR if need be.
IContentTemplate contentTemplate = null; | ||
ILookupTemplate<IFhirTemplate> fhirTemplate = null; | ||
|
||
if (!string.IsNullOrEmpty(deviceMappingContent)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This check and the one below are redundant based on the check above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The above check ensures that at least one of the mapping templates are provided. It's still acceptable to provide a single template and leave the other null. For example, if a user is creating a new IotConnector they most likely start with the Device Template. In that case they won't have a FhirTemplate to validate. So we need the checks here to determine which ones are provided.
var fhirTemplateValues = new List<FhirValueType>(); | ||
fhirTemplateValues.Add(matchingFhirTemplate.Value); | ||
|
||
if (matchingFhirTemplate.Components != null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that matchingFhirTemplate.Components and matchingFhirTemplate.Value are mutually exclusive. An example of this would be blood pressure. We would have the 2 components for diastolic and systolic, but there would be no value at the root.
This Pr creates a new package which will hold logic that validates IotConnector template files. In addition it allows sample device data to be executed against template files in order to capture errors/warnings.