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)); } }