You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
2.1 KiB

package pain
import (
"regexp"
)
var (
ISODateTime = regexp.MustCompile(`\d{4}(-\d\d){2}T\d\d(:\d\d){2}`)
RestrictedIdentificationSEPA1 = regexp.MustCompile(`([A-Za-z0-9]|[\+|\?|/|\-|:|\(|\)|\.|,|'| ]){1,35}`)
RestrictedIdentificationSEPA2 = regexp.MustCompile(`([A-Za-z0-9]|[\+|\?|/|\-|:|\(|\)|\.|,|']){1,35}`)
Max15NumericText = regexp.MustCompile(`[0-9]{1,15}`)
RestrictedDecimalNumber = regexp.MustCompile(`[+-]?\d+\.\d\d`)
Max70Text = regexp.MustCompile(`.{1,70}`)
Max140Text = regexp.MustCompile(`.{1,140}`)
ServiceLevelSEPACode = regexp.MustCompile(`SEPA`)
SequenceType1Code = regexp.MustCompile(`FRST|RCUR|FNAL|OOFF`)
PaymentMethod2Code = regexp.MustCompile(`DD`)
LocalInstrumentSEPACode = regexp.MustCompile(`CORE|B2B`)
IBAN2007Identifier = regexp.MustCompile(`[A-Z]{2,2}[0-9]{2,2}[a-zA-Z0-9]{1,30}`)
RestrictedPersonIdentifierSEPA = regexp.MustCompile(`[a-zA-Z]{2,2}[0-9]{2,2}([A-Za-z0-9]|[\+|\?|/|\-|:|\(|\)|\.|,|']){3,3}([A-Za-z0-9]|[\+|\?|/|\-|:|\(|\)|\.|,|']){1,28}`)
BICIdentifier = regexp.MustCompile(`[A-Z]{6,6}[A-Z2-9][A-NP-Z0-9]([A-Z0-9]{3,3}){0,1}`)
)
var (
SEPARegexps = map[string]*regexp.Regexp{
"BIC": BICIdentifier,
"CreDtTm": ISODateTime,
"CtrlSum": RestrictedDecimalNumber,
"EndToEndId": RestrictedIdentificationSEPA1,
"IBAN": IBAN2007Identifier,
"Id": RestrictedPersonIdentifierSEPA,
"InstrId": RestrictedIdentificationSEPA1,
"InstdAmt": RestrictedDecimalNumber, // Note: this is for the value
"MsgId": RestrictedIdentificationSEPA1,
"MndtId": RestrictedIdentificationSEPA2,
"NbOfTxs": Max15NumericText,
"Nm": Max70Text,
"PmtInfId": RestrictedIdentificationSEPA1,
"PmtMetaLclInstrm": LocalInstrumentSEPACode,
"PmtMetaSvcLvl": ServiceLevelSEPACode,
"PmtMtd": PaymentMethod2Code,
"ReqdColltnDt": ISODateTime,
"SeqTp": SequenceType1Code,
"Ustrd": Max140Text,
}
)