validation-helper
Example
const validationHelper = require('@mimik/validation-helper');
-
validation-helper
-
~validateCompositeId(id) ⇒
string
-
~validateOauthId(id, userId, onBehalfId) ⇒
string
-
~validateLocalLinkNetworkId() ⇒
string
-
~validateLocation(lon, lat, elevation, type) ⇒
object
-
~validateGeoLocation(location) ⇒
object
-
~validateUniqueAttributes(attributes) ⇒
Array.<object>
-
~validateCompositeId(id) ⇒
string
validation-helper~validateCompositeId(id) ⇒ A composite id is a base64 encoded object with the following structure:
{
"nodeId": (a string),
"localLinkNetworkId": (a string)
}
Kind: inner method of validation-helper
Returns: string
- The id.
Category: sync
Throws:
-
object
An error with the appropriate message.
Param | Type | Description |
---|---|---|
id | string |
Id to validate as a composite id. |
string
validation-helper~validateOauthId(id, userId, onBehalfId) ⇒ Validate oauth id.
Kind: inner method of validation-helper
Returns: string
- The userid
or the onbehalfId
.
Category: sync
Throws:
-
object
Will throw an error is no match is made.
Param | Type | Description |
---|---|---|
id | string |
The id to validate. |
userId | string |
The userId to validate the id against. |
onBehalfId | string |
The onBehalfId to validate the id against. |
string
validation-helper~validateLocalLinkNetworkId() ⇒ The localLinkNetwork id is a base64 encoded object with the following structure:
{
"networkAddress": (an address),
"publicAddress": (an address)
}
The publicAddress
is not optional.
If the localLinkNetwork
is not present, the networkAddress is not optional and the returned localLinkNetworkId will be build.
Kind: inner method of validation-helper
Returns: string
- The localLinkNetwork id.
Category: sync
Throws:
-
object
Will throw an error with the appropriate message.
Params: string
localLinkNetworkId - The id to validate.
Params: IP<string>
networkAddress - An address to validate the id.
Params: IP<string>
publicAddress - An address to validate the id.
object
validation-helper~validateLocation(lon, lat, elevation, type) ⇒ The location object has the following structure:
{
"type": "Point",
"coordinates": [lon, lat],
"elevation": (elevation), if present
}
Kind: inner method of validation-helper
Returns: object
- The location object.
Category: sync
Throws:
-
object
Will throw an error with the appropriate message.
Param | Type | Description |
---|---|---|
lon | number |
Longitude (-180, 180) in degree. |
lat | number |
Latitude (-90, 90) in degree. |
elevation | number |
Elevation (-5000, 50000) in meters. |
type | string |
Type of coordinates (Point). |
object
validation-helper~validateGeoLocation(location) ⇒ If location is not present `null will be returned.
Kind: inner method of validation-helper
Returns: object
- The location.
Category: sync
Throws:
- Will throw an error if the location fails validation.
Param | Type | Description |
---|---|---|
location | object |
A GeoJSON location object. |
Array.<object>
validation-helper~validateUniqueAttributes(attributes) ⇒ Validate unique attributes.
Kind: inner method of validation-helper
Returns: Array.<object>
- An array of unique attributes.
Category: sync
Param | Type | Description |
---|---|---|
attributes | Array.<object> |
An array of attributes. |