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.")); }
public void Validate_returns_true_for_valid_postcode() { var result = _client.Validate("GU1 1AA"); Assert.True(result); }
public static async Task <bool> ValidateAsync(this PostcodesIOClient client, string postcode) { return(await Task.Run(() => client.Validate(postcode))); }