/// <summary> /// Validates whether the contents of the resource would be acceptable as a create /// </summary> /// <typeparam name="TResource"></typeparam> /// <param name="resource">The entry containing the Resource data to use for the validation</param> /// <param name="result">Contains the OperationOutcome detailing why validation failed, or null if validation succeeded</param> /// <param name="tags">Optional list of tags to attach to the resource</param> /// <returns>True when validation was successful, false otherwise. Note that this function may still throw exceptions if non-validation related /// failures occur.</returns> public bool TryValidateCreate <TResource>(TResource resource, out OperationOutcome result, IEnumerable <Tag> tags = null) where TResource : Resource, new() { if (resource == null) { throw new ArgumentNullException("resource"); } var collection = typeof(Resource).GetCollectionName(); var url = new RestUrl(_endpoint).Validate(collection); result = doValidate(url, resource, tags); return(result == null || !result.Success()); }
/// <summary> /// Validates whether the contents of the resource would be acceptable as an update /// </summary> /// <param name="entry">The entry containing the updated Resource to validate</param> /// <param name="result">Contains the OperationOutcome detailing why validation failed, or null if validation succeeded</param> /// <returns>True when validation was successful, false otherwise. Note that this function may still throw exceptions if non-validation related /// failures occur.</returns> public bool TryValidateUpdate <TResource>(ResourceEntry <TResource> entry, out OperationOutcome result) where TResource : Resource, new() { if (entry == null) { throw new ArgumentNullException("entry"); } if (entry.Resource == null) { throw new ArgumentException("Entry does not contain a Resource to validate", "entry"); } if (entry.Id == null) { throw new ArgumentException("Entry needs a non-null entry.id to use for validation", "entry"); } var id = new ResourceIdentity(entry.Id); var url = new RestUrl(_endpoint).Validate(id.Collection, id.Id); result = doValidate(url, entry.Resource, entry.Tags); return(result == null || !result.Success()); }