Exemplo n.º 1
0
        protected override ValidationResult IsValid(object value, ValidationContext validationContext)
        {
            PostcodesIOClient client = new PostcodesIOClient();

            var result = client.Validate(value as string);

            if (result)
            {
                return(ValidationResult.Success);
            }

            return(new ValidationResult("The postcode given is not valid."));
        }
Exemplo n.º 2
0
        public void Validate_returns_true_for_valid_postcode()
        {
            var result = _client.Validate("GU1 1AA");

            Assert.True(result);
        }
Exemplo n.º 3
0
 public static async Task <bool> ValidateAsync(this PostcodesIOClient client, string postcode)
 {
     return(await Task.Run(() => client.Validate(postcode)));
 }