public static Bic Create( string institutionCode, string countryCode, string locationCode, string branchCode, BicVersion version) { Require.NotNull(institutionCode, nameof(institutionCode)); Require.NotNull(countryCode, nameof(countryCode)); Require.NotNull(locationCode, nameof(locationCode)); Require.NotNull(branchCode, nameof(branchCode)); Require.True(InstitutionPart.Validate(institutionCode, version), nameof(institutionCode)); Require.True(CountryPart.Validate(countryCode), nameof(countryCode)); Require.True(LocationPart.Validate(locationCode), nameof(locationCode)); Require.True(BranchPart.Validate(branchCode), nameof(branchCode)); return(new Bic(institutionCode, countryCode, locationCode, branchCode)); }
public static Outcome <Bic> TryParse(string value, BicVersion version) { if (value == null || !CheckLength(value)) { return(Outcome <Bic> .FromError(Format.Current(Strings.InvalidBicValue, value))); } string institutionCode = InstitutionPart.FromBic(value, version); if (institutionCode == null) { return(Outcome <Bic> .FromError(Format.Current(Strings.InvalidInput_InstitutionCode, value))); } string countryCode = CountryPart.FromBic(value); if (countryCode == null) { return(Outcome <Bic> .FromError(Format.Current(Strings.InvalidInput_CountryCode, value))); } string locationCode = LocationPart.FromBic(value); if (locationCode == null) { return(Outcome <Bic> .FromError(Format.Current(Strings.InvalidInput_LocationCode, value))); } string branchCode = BranchPart.FromBic(value); if (branchCode == null) { return(Outcome <Bic> .FromError(Format.Current(Strings.InvalidInput_BranchCode, value))); } return(Outcome.Of(new Bic(institutionCode, countryCode, locationCode, branchCode, value))); }
public static Bic?Parse(string value, BicVersion version) { if (value == null || !CheckLength(value)) { return(null); } string institutionCode = InstitutionPart.FromBic(value, version); if (institutionCode == null) { return(null); } string countryCode = CountryPart.FromBic(value); if (countryCode == null) { return(null); } string locationCode = LocationPart.FromBic(value); if (locationCode == null) { return(null); } string branchCode = BranchPart.FromBic(value); if (branchCode == null) { return(null); } return(new Bic(institutionCode, countryCode, locationCode, branchCode, value)); }