public static SerialNumber ToString(SerialNumberNumeric serialNumberNumeric) { var unvalidatedSerialNumber = Utilities.ToUnvalidatedString(serialNumberNumeric); var serialNumber = Utilities.Validate(unvalidatedSerialNumber); return(serialNumber); }
public static UnvalidatedSerialNumber ToUnvalidatedString(SerialNumberNumeric serialNumberNumeric) { var valueString = Utilities.DefaultSerialNumberToStringConverter(serialNumberNumeric.Value); var unvalidatedSerialNumber = new UnvalidatedSerialNumber(valueString); return(unvalidatedSerialNumber); }
public static void Validate(this SerialNumberNumeric serialNumberNumeric) { var isValid = serialNumberNumeric.IsValid(); if (!isValid.Value) { throw new ArgumentException(isValid.Message, nameof(serialNumberNumeric)); } }
public static DescribedResult <bool> TryValidate(UnvalidatedSerialNumberNumeric unvalidatedSerialNumberNumeric, out SerialNumberNumeric serialNumberNumeric) { var isValid = Utilities.IsValid(unvalidatedSerialNumberNumeric); if (isValid.Value) { serialNumberNumeric = new SerialNumberNumeric(unvalidatedSerialNumberNumeric.Value); } else { serialNumberNumeric = SerialNumberNumeric.Invalid; } return(isValid); }
public static DescribedResult <bool> IsValid(SerialNumberNumeric serialNumberNumeric) { var output = Utilities.IsValidSerialNumber(serialNumberNumeric.Value); return(output); }
public static DescribedResult <bool> TryValidate(UnvalidatedSerialNumberNumeric unvalidatedSerialNumberNumeric, out SerialNumberNumeric serialNumberNumeric) { var isValid = Utilities.TryValidate(unvalidatedSerialNumberNumeric, out serialNumberNumeric); return(isValid); }