public virtual IEnumerable <ValidationResult> Validate(ValidationContext validationContext) { var result = new List <ValidationResult>(); if (Id != null && !Id.IsAbsoluteUri) { result.Add(FhirValidator.BuildResult(validationContext, "Entry id must be an absolute URI")); } if (Bundle.UriHasValue(SelfLink) && !SelfLink.IsAbsoluteUri) { result.Add(FhirValidator.BuildResult(validationContext, "Entry selflink must be an absolute URI")); } if (Links.FirstLink != null || Links.LastLink != null || Links.PreviousLink != null || Links.NextLink != null) { result.Add(FhirValidator.BuildResult(validationContext, "Paging links can only be used on feeds, not entries")); } if (Tags != null && validationContext.ValidateRecursively()) { FhirValidator.TryValidate(Tags, result, true); } return(result); }
public virtual IEnumerable <ValidationResult> Validate(ValidationContext validationContext) { // TODO: Contained resources share the same internal id resolution space as the parent // resource -> verify id uniqueness var result = new List <ValidationResult>(); // Validate specific invariants for contained items. The content of the contained // items is validated by the "normal" validation triggered by the FhirElement attribute if (Contained != null) { foreach (var contained in Contained) { if (contained.Contained != null && contained.Contained.Any()) { result.Add(FhirValidator.BuildResult(validationContext, "Contained resources cannot contain nested contained resources")); } if (contained.Text != null) { result.Add(FhirValidator.BuildResult(validationContext, "Contained resources should not contain narrative")); } } } return(result); }
public override IEnumerable <ValidationResult> Validate(ValidationContext validationContext) { var result = new List <ValidationResult>(); result.AddRange(base.Validate(validationContext)); if (Content == null) { result.Add(FhirValidator.BuildResult(validationContext, "Entry must contain (possibly 0-length) data in Content element")); } if (ContentType == null) { result.Add(FhirValidator.BuildResult(validationContext, "Entry must contain a ContentType")); } return(result); }
public IEnumerable <ValidationResult> Validate(ValidationContext validationContext) { var result = new List <ValidationResult>(); //if (String.IsNullOrWhiteSpace(Title)) // result.Add(new ValidationResult("Feed must contain a title", FhirValidator.SingleMemberName("Title")); //if (!UriHasValue(Id)) // result.Add(new ValidationResult("Feed must have an id")); //else // if (!Id.IsAbsoluteUri) // result.Add(new ValidationResult("Feed id must be an absolute URI")); if (Id != null && !Id.IsAbsoluteUri) { result.Add(FhirValidator.BuildResult(validationContext, "Feed id must be an absolute URI")); } //if (LastUpdated == null) // result.Add(new ValidationResult("Feed must have a updated date")); if (Links.SearchLink != null) { result.Add(FhirValidator.BuildResult(validationContext, "Links with rel='search' can only be used on feed entries")); } bool feedHasAuthor = !String.IsNullOrEmpty(this.AuthorName); if (Entries != null && validationContext.ValidateRecursively()) { foreach (var entry in Entries.Where(e => e != null)) { if (!feedHasAuthor && entry is ResourceEntry && String.IsNullOrEmpty(((ResourceEntry)entry).AuthorName)) { result.Add(FhirValidator.BuildResult(validationContext, "Bundle's author and Entry author cannot both be empty")); } FhirValidator.TryValidate(entry, result, validationContext.ValidateRecursively()); } } return(result); }