func validateBbanLength(value string, structure bban.Structure) error { bban := extractBban(value) if len(bban) != structure.Length() { return ErrInvalidBbanLength } return nil }
func validateBbanStructure(value string, structure bban.Structure) error { bban := extractBban(value) offset := 0 for _, part := range structure.Parts() { value := bban[offset : offset+part.Length] ok := part.Validate(value) if !ok { return ErrInvalidBbanPart } offset += part.Length } return nil }