protected override ValidationResult IsValid(object value, ValidationContext validationContext)
        {
            if (value == null)
            {
                return(ValidationResult.Success);
            }

            if (value.GetType() != typeof(string))
            {
                throw new ArgumentException("CodePatternAttribute can only be applied to string properties");
            }

            if (XHtml.IsValidValue(value as string))
            {
                return(ValidationResult.Success);
            }
            else
            {
                return(DotNetAttributeValidation.BuildResult(validationContext, "Xml can not be parsed or is not valid according to the (limited) FHIR scheme"));
            }
        }
Example #2
0
        protected override ValidationResult IsValid(object value, ValidationContext validationContext)
        {
            if (value == null)
            {
                return(ValidationResult.Success);
            }

            if (value.GetType() != typeof(string))
            {
                throw new ArgumentException("UriPatternAttribute can only be applied to .NET Uri properties");
            }

            if (!FhirUri.IsValidValue(value as string))
            {
                return(DotNetAttributeValidation.BuildResult(validationContext, "Uri uses an urn:oid or urn:uuid scheme, but the syntax {0} is incorrect", value as string));
            }
            else
            {
                return(ValidationResult.Success);
            }
        }
Example #3
0
        protected override ValidationResult IsValid(object value, ValidationContext validationContext)
        {
            if (value == null)
            {
                return(ValidationResult.Success);
            }

            if (value.GetType() != typeof(string))
            {
                throw new ArgumentException("OidPatternAttribute can only be applied to string properties");
            }

            if (Oid.IsValidValue(value as string))
            {
                return(ValidationResult.Success);
            }
            else
            {
                return(DotNetAttributeValidation.BuildResult(validationContext, "{0} is not a correctly formatted Oid", (string)value));
            }
        }
        protected override ValidationResult IsValid(object value, ValidationContext validationContext)
        {
            if (value == null)
            {
                return(ValidationResult.Success);
            }

            if (value.GetType() != typeof(DateTimeOffset))
            {
                throw new ArgumentException("IdPatternAttribute can only be applied to DateTimeOffset properties");
            }

            if (Instant.IsValidValue(value as string))
            {
                return(ValidationResult.Success);
            }
            else
            {
                return(DotNetAttributeValidation.BuildResult(validationContext, "{0} is not a correctly formatted Instant", value as string));
            }
        }