structref

package module
v0.0.0-...-13d9646 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 4, 2018 License: Apache-2.0 Imports: 4 Imported by: 1

README

Golang support for structured references

Package structref contains data types and validation functions for structured references used on Swiss payment slips: creditor references as described in ISO 11649, and Swiss ESR numbers. This is not an officially supported Google product.

The types for different structured references all implement the Printer interface defined in this package:

type Printer interface {
  DigitalFormat() string
  PrintFormat() string
}

Documentation

Overview

Package structref contains data types and validation functions for structured references: IBAN numbers, creditor references as described in ISO 11649, and Swiss ESR numbers.

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CreditorReference

type CreditorReference struct {
	// contains filtered or unexported fields
}

CreditorReference contains a creditor reference as described in ISO 11649. It implements fmt.Stringer interface as well as the interface structref.Printer defined in this package.

Example
ref, err := NewCreditorReference("RF18 5390 0754 7034")
fmt.Println(ref.DigitalFormat())
fmt.Println(ref.PrintFormat())
fmt.Println(err)
Output:

RF18539007547034
RF18 5390 0754 7034
<nil>

func NewCreditorReference

func NewCreditorReference(ref string) (*CreditorReference, error)

NewCreditorReference creates a filled-in validated CreditorReference, or returns an error if the supplied ref string does not represent a valid creditor reference.

func NewCreditorReferenceOrDie

func NewCreditorReferenceOrDie(ref string) *CreditorReference

NewCreditorReferenceOrDie either returns a filled-in validated creditor reference, or aborts the program on error.

func NewPaddedCreditorReference

func NewPaddedCreditorReference(ref string) (*CreditorReference, error)

NewPaddedCreditorReference is like NewCreditorReference but guarantees that the returned CreditorReference is exactly 25 characters by padding the root with zeros.

func NewPaddedCreditorReferenceOrDie

func NewPaddedCreditorReferenceOrDie(ref string) *CreditorReference

NewPaddedCreditorReferenceOrDie either returns a filled-in validated creditor reference, or aborts the program on error.

func (*CreditorReference) DigitalFormat

func (ref *CreditorReference) DigitalFormat() string

DigitalFormat returns the creditor reference in digital format: the “RF” prefix followed by the two check digits and then the root.

func (*CreditorReference) PrintFormat

func (ref *CreditorReference) PrintFormat() string

PrintFormat returns the creditor reference in space-separated groups.

func (*CreditorReference) String

func (ref *CreditorReference) String() string

String returns a plain string representation of a CreditorReference.

type Printer

type Printer interface {
	// A format suitable for digital distribution.
	// This typically means a string with no spaces.
	DigitalFormat() string

	// A format suitable for print.
	// This typically means a string with space-separated groups of
	// characters for more easy reading and human verification.
	PrintFormat() string
}

Printer defines methods for outputting structured identifiers.

type ReferenceNumber

type ReferenceNumber struct {
	// contains filtered or unexported fields
}

ReferenceNumber contains a reference number as used on the orange payment slip (Einzahlungsschein mit Referenznummer, ESR) in Switzerland. It implements fmt.Stringer interface as well as the interface structref.Printer defined in this package.

Example
ref, err := NewReferenceNumber("210000000003139471430009017")
fmt.Println(ref.DigitalFormat())
fmt.Println(ref.PrintFormat())
fmt.Println(err)
Output:

210000000003139471430009017
21 00000 00003 13947 14300 09017
<nil>

func NewReferenceNumber

func NewReferenceNumber(ref string) (*ReferenceNumber, error)

NewReferenceNumber creates a filled-in validated CreditorReference, or returns an error if the supplied ref string does not represent a valid creditor reference.

func NewReferenceNumberOrDie

func NewReferenceNumberOrDie(ref string) *ReferenceNumber

NewReferenceNumberOrDie either returns a filled-in validated reference number, or aborts the program on error.

func (*ReferenceNumber) DigitalFormat

func (ref *ReferenceNumber) DigitalFormat() string

DigitalFormat returns the reference number digital format: no spaces.

func (*ReferenceNumber) PrintFormat

func (ref *ReferenceNumber) PrintFormat() string

PrintFormat returns the reference number in space-separated groups.

func (*ReferenceNumber) String

func (ref *ReferenceNumber) String() string

String returns a plain string representation of a CreditorReference.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL