utils

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2022 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNonAlphanumeric is given when a field has non-alphanumeric characters
	ErrNonAlphanumeric = errors.New("has non alphanumeric characters")
	// ErrUpperAlpha is given when a field is not numeric characters
	ErrNumeric = errors.New("is not numeric characters")
	// ErrUpperAlpha is given when a field is an invalid phone number
	ErrPhoneNumber = errors.New("is an invalid phone number")
	// ErrValidYear is given when there's an invalid date
	ErrValidDate = errors.New("is an invalid Date")
	// ErrValidYear is given when a segment has an invalid length
	ErrRecordLength = errors.New("has an invalid length")
	// ErrValidField is given when there's an invalid field
	ErrValidField = errors.New("is an invalid field")
	// ErrShortRecord is given when the record is too short
	ErrShortRecord = errors.New("is too short / missing data")
	// ErrEmail is given when a field is not email
	ErrEmail = errors.New("is not email address")
	// ErrPayeeExtBlock is given when payee record has not extension block for  for each type of return
	ErrPayeeExtBlock = errors.New("should exist extension block")
	// ErrInvalidAscii is given when is invalid ascii
	ErrInvalidAscii = errors.New("is invalid ascii")
	// ErrInvalidFile is given when is invalid file
	ErrInvalidFile = errors.New("is invalid file")
	// ErrNonExistPayer is given when isn't payer record
	ErrNonExistPayer = errors.New("should exist payer record")
	// ErrNonExistEndPayer is given when isn't payer record
	ErrNonExistEndPayer = errors.New("should exist end of payer record")
	// ErrNonExistPayee is given when isn't payee record
	ErrNonExistPayee = errors.New("should exist at least one payee record")
	// ErrInvalidNumberPayees is given when has incorrect number of payees
	ErrInvalidNumberPayees = errors.New("has incorrect number of payees")
	// ErrIncorrectReturnIndicator is given when has incorrect return indicator
	ErrIncorrectReturnIndicator = errors.New("has incorrect return indicator")
	// ErrInvalidTotalAmounts is given when have invalid totals of any payment amount fields
	ErrInvalidTotalAmounts = errors.New("have invalid totals of any payment amount fields")
	// ErrUnexpectedPaymentAmount is given when has unexpected payment amount in B records
	ErrUnexpectedPaymentAmount = errors.New("has unexpected payment amount")
	// ErrUnexpectedTotalAmount is given when has unexpected totals of any payment amount in C,K record
	ErrUnexpectedTotalAmount = errors.New("has unexpected totals of any payment amount")
	// ErrInvalidTypeOfReturn is given when has invalid type of return
	ErrInvalidTypeOfReturn = errors.New("has invalid type of return")
	// ErrDuplicatedFSCode is given when has duplicated combined fs code in state records
	ErrDuplicatedFSCode = errors.New("has duplicated combined fs code")
	// ErrInvalidNumberPayers is given when has incorrect number of payers
	ErrInvalidNumberPayers = errors.New("has incorrect number of payers")
	// ErrInvalidTCC is given when is invalid transmitter control code
	ErrInvalidTCC = errors.New("is invalid transmitter control code")
	// ErrUnsupportedBlock is given when is not supported extension block of B record
	ErrUnsupportedBlock = errors.New("is not supported extension block of B record")
	// ErrUnknownPdfTemplate is given when is unknown pdf template
	ErrUnknownPdfTemplate = errors.New("is unknown pdf template")
	// ErrFdfGenerate is given when failed to generate fdf file
	ErrFdfGenerate = errors.New("failed to generate fdf file")
	// ErrPdfMerge is given when failed to merge pdf files
	ErrPdfMerge = errors.New("failed to merge pdf files")
	// ErrCFSFProgram is given when has invalid CF/SF program
	ErrCFSFProgram = errors.New("should be payee B records and the state totals K records")
	// ErrCFSFState is given when has invalid Combined Federal/State Code
	ErrCFSFState = errors.New("is invalid combined federal/tate code in K record")
	// ErrUnknownEncryptionType is given when is unknown encryption type
	ErrUnknownEncryptionType = errors.New("is unknown encryption type")
	// ErrNullFile is given when has null file
	ErrNullFile = errors.New("has null file")
	// ErrInvalidNonceLength is given when has invalid nonce length
	ErrInvalidNonceLength = errors.New("crypto/cipher: incorrect nonce length given to GCM")
	// ErrUnsupportedPdf is given when is unsupported pdf logic
	ErrUnsupportedPdf = errors.New("is unsupported pdf")
	// ErrUnsupportedField is given when is not supported field of B record
	ErrUnsupportedField = errors.New("is not supported field of B record")
)

Functions

func CheckAvailableCodes added in v0.1.4

func CheckAvailableCodes(codes string, codeMap map[string]string) bool

to check amount codes

func CopyStruct

func CopyStruct(from interface{}, to interface{})

to copy fields between struct instances

func GetField

func GetField(from interface{}, fieldName string) (reflect.Value, error)

to get field

func IsNumeric added in v0.1.4

func IsNumeric(data string) error

func NewErrFieldRequired

func NewErrFieldRequired(field string) error

NewErrFieldRequired returns a error that has empty required field

func NewErrRecordSequenceNumber

func NewErrRecordSequenceNumber(field string) error

NewErrRecordSequenceNumber returns a error that has invalid record sequence number

func NewErrRecordType added in v0.1.4

func NewErrRecordType(field string) error

NewErrRecordType returns a error that has invalid record type

func NewErrUnexpectedRecord

func NewErrUnexpectedRecord(name string, record interface{}) error

NewErrUnexpectedRecord returns a error that has unexpected record

func NewErrValidValue

func NewErrValidValue(field string) error

NewErrValidValue returns a error that has invalid value

func ParseValue

func ParseValue(fields reflect.Value, spec map[string]config.SpecField, record string) error

parse field with string

func RandAlphanumericString added in v0.1.4

func RandAlphanumericString(n int) (string, error)

RandAlphanumericString returns a securely generated random string.

func ToString

func ToString(elm config.SpecField, data reflect.Value) string

to string from field

func Validate

func Validate(r interface{}, spec map[string]config.SpecField, rType string) error

to validate fields of record

func ValidateCombinedFSCode added in v0.1.4

func ValidateCombinedFSCode(code int) error

Types

This section is empty.

Jump to

Keyboard shortcuts

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