Ejemplo n.º 1
0
func validateBbanLength(value string, structure bban.Structure) error {
	bban := extractBban(value)
	if len(bban) != structure.Length() {
		return ErrInvalidBbanLength
	}
	return nil
}
Ejemplo n.º 2
0
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
}