示例#1
0
        public static CheckDigitString ToString(UnvalidatedCheckDigit unvalidatedCheckDigit)
        {
            var unvalidatedCheckDigitString = Utilities.ToUnvalidatedString(unvalidatedCheckDigit);

            var checkDigitString = Utilities.Validate(unvalidatedCheckDigitString);

            return(checkDigitString);
        }
示例#2
0
        public static UnvalidatedCheckDigitString ToUnvalidatedString(UnvalidatedCheckDigit unvalidatedCheckDigit)
        {
            var unvalidatedCheckDigitStringValue = Utilities.DefaultCheckDigitToStringConverter(unvalidatedCheckDigit.Value);

            var unvalidatedCheckDigitString = new UnvalidatedCheckDigitString(unvalidatedCheckDigitStringValue);

            return(unvalidatedCheckDigitString);
        }
示例#3
0
        public static UnvalidatedCheckDigit ToUnvalidatedNumeric(CheckDigitString checkDigitString)
        {
            var unvalidatedCheckDigitValue = Utilities.DefaultCheckDigitToNumericConverter(checkDigitString.Value);

            var unvalidatedCheckDigit = new UnvalidatedCheckDigit(unvalidatedCheckDigitValue);

            return(unvalidatedCheckDigit);
        }
示例#4
0
        public static CheckDigit Validate(UnvalidatedCheckDigit unvalidatedCheckDigit)
        {
            var isValid = Utilities.TryValidate(unvalidatedCheckDigit, out var checkDigit);

            if (!isValid.Value)
            {
                throw new ArgumentException(isValid.Message, nameof(unvalidatedCheckDigit));
            }

            return(checkDigit);
        }
示例#5
0
        public static DescribedResult <bool> TryValidate(UnvalidatedCheckDigit unvalidatedCheckDigit, out CheckDigit checkDigit)
        {
            var isValid = Utilities.IsValid(unvalidatedCheckDigit);

            if (isValid.Value)
            {
                checkDigit = new CheckDigit(unvalidatedCheckDigit.Value);
            }
            else
            {
                checkDigit = CheckDigit.Invalid;
            }

            return(isValid);
        }
示例#6
0
        public static DescribedResult <bool> IsValid(UnvalidatedCheckDigit unvalidatedCheckDigit)
        {
            var output = Utilities.IsValidCheckDigit(unvalidatedCheckDigit.Value);

            return(output);
        }