public int Add(String input) { List <int> allNumbers = numberExtractor.Extract(input); List <int> numbersWithoutIgnored = numberRemover.RemoveNumbersToIgnore(allNumbers); numberValidator.Validate(numbersWithoutIgnored); return(SumNumbers(numbersWithoutIgnored)); }
public string Format(string number) { if (false == _validator.Validate(number)) { throw new FormatException(_validator.ErrorMessage); } var code = number.Substring(0, 3); var digits = int.Parse(number.Substring(3)); return(string.Format(_format, code, digits)); }
public IHttpActionResult Validate(NumberDTO numberDTO) { if (false == ModelState.IsValid) { return(BadRequest(GetModelErrorMessage())); } var number = numberDTO.Number; var valid = _validator.Validate(number); return(Ok(new ValidationResultDTO(valid))); }