public static IbanParts?Parse(string value) { if (value == null || !CheckLength(value)) { return(null); } string countryCode = CountryPart.FromIban(value); if (countryCode == null) { return(null); } string checkDigits = CheckDigitsPart.FromIban(value); if (checkDigits == null) { return(null); } string bban = BbanPart.FromIban(value); if (bban == null) { return(null); } return(new IbanParts(countryCode, checkDigits, bban, value)); }
public static Outcome <IbanParts> TryParse(string value) { if (value == null || !CheckLength(value)) { return(Outcome <IbanParts> .FromError(Format.Current(Strings.InvalidIbanValue, value))); } string countryCode = CountryPart.FromIban(value); if (countryCode == null) { return(Outcome <IbanParts> .FromError(Format.Current(Strings.InvalidInput_CountryCode, value))); } string checkDigits = CheckDigitsPart.FromIban(value); if (checkDigits == null) { return(Outcome <IbanParts> .FromError(Format.Current(Strings.InvalidInput_CheckDigits, value))); } string bban = BbanPart.FromIban(value); if (bban == null) { return(Outcome <IbanParts> .FromError(Format.Current(Strings.InvalidInput_Bban, value))); } return(Outcome.Of(new IbanParts(countryCode, checkDigits, bban, value))); }
public static IbanParts Create(string countryCode, string checkDigits, string bban) { Require.NotNull(countryCode, nameof(countryCode)); Require.NotNull(checkDigits, nameof(checkDigits)); Require.NotNull(bban, nameof(bban)); Require.True(CountryPart.Validate(countryCode), nameof(countryCode)); Require.True(CheckDigitsPart.Validate(checkDigits), nameof(checkDigits)); Require.True(BbanPart.Validate(bban), nameof(bban)); return(new IbanParts(countryCode, checkDigits, bban)); }
public static IbanParts Build(string countryCode, string bban) { Require.NotNull(countryCode, nameof(countryCode)); Require.NotNull(bban, nameof(bban)); Require.True(CountryPart.Validate(countryCode), nameof(countryCode)); Require.True(BbanPart.Validate(bban), nameof(bban)); string checkDigits = IbanCheckDigits.Compute(countryCode, bban); return(new IbanParts(countryCode, checkDigits, bban)); }