Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DB ¶
type DB interface { // Must find the record that corresponds to // LOCODE and provides the Record interface. // // Must return an error if Record is nil. // // LOCODE is always non-nil. Get(*locode.LOCODE) (Record, error) }
DB is an interface of read-only NeoFS LOCODE database.
type Prm ¶
type Prm struct { // NeoFS LOCODE database interface. // // Must not be nil. DB DB }
Prm groups the required parameters of the Validator's constructor.
All values must comply with the requirements imposed on them. Passing incorrect parameter values will result in constructor failure (error or panic depending on the implementation).
type Record ¶
type Record interface { // Must return ISO 3166-1 alpha-2 // country code. // // Must not return nil. CountryCode() *locodedb.CountryCode // Must return English short country name // officially used by the ISO 3166 // Maintenance Agency (ISO 3166/MA). CountryName() string // Must return UN/LOCODE 3-character code // for the location (numerals 2-9 may also // be used). // // Must not return nil. LocationCode() *locodedb.LocationCode // Must return name of the location which // have been allocated a UN/LOCODE without // diacritic sign. LocationName() string // Must return ISO 1-3 character alphabetic // and/or numeric code for the administrative // division of the country concerned. SubDivCode() string // Must return subdivision name. SubDivName() string // Must return existing continent where is // the location. // // Must not return nil. Continent() *locodedb.Continent }
Record is an interface of read-only NeoFS LOCODE database single entry.
type Validator ¶
type Validator struct {
// contains filtered or unexported fields
}
Validator is an utility that verifies and updates node attributes associated with its geographical location (LOCODE).
For correct operation, Validator must be created using the constructor (New) based on the required parameters and optional components. After successful creation, the Validator is immediately ready to work through API.
func New ¶
New creates a new instance of the Validator.
Panics if at least one value of the parameters is invalid.
The created Validator does not require additional initialization and is completely ready for work.
func (*Validator) VerifyAndUpdate ¶
VerifyAndUpdate validates UN-LOCODE attribute of n and adds a group of related attributes.
If n does not contain UN-LOCODE attribute, nil is returned without any actions. Otherwise, if UN-LOCODE value does not match the UN/LOCODE format, an error returns.
New attributes are formed from the record of DB instance (Prm). If DB entry R was found w/o errors, then new attributes are:
- CountryCode: R.CountryCode().String();
- Country: R.CountryName();
- LocationCode: R.LocationCode().String();
- Location: Record.LocationName();
- SubDivCode: R.SubDivCode();
- SubDiv: R.SubDivName();
- Continent: R.Continent().String().
UN-LOCODE attribute remains untouched.