@mimik/validation-helper v2.0.2
validation-helper
Example
import validationHelper from '@mimik/validation-helper';
or
import { validateCompositeId } from '@mimik/validation-helper';- validation-helper
- ~validateCompositeId(id) ⇒ object
- ~validateOauthId(id, userId, onBehalfId) ⇒ string
- ~validateLocalLinkNetworkId(localLinkNetworkId, networkAddress, publicAddress) ⇒ string
- ~validateLocation(lon, lat, [elevation], type) ⇒ object | null
- ~validateGeoLocation(location) ⇒ object | null
- ~validateUniqueAttributes(attributes) ⇒ boolean
validation-helper~validateCompositeId(id) ⇒ object
A composite id is a base64 encoded object with the following structure:
{
"nodeId": (string),
"localLinkNetworkId": (string)
}Kind: inner method of validation-helper
Returns: object - The decoded composite id object.
Category: sync
Throws:
- Error If the id is not a valid base64 composite.
| Param | Type | Description |
|---|---|---|
| id | string | Id to validate as a composite id. |
validation-helper~validateOauthId(id, userId, onBehalfId) ⇒ string
Validate oauth id.
Kind: inner method of validation-helper
Returns: string - The validated id.
Category: sync
Throws:
- Error If validation fails.
| Param | Type | Description |
|---|---|---|
| id | string | The id to validate. |
| userId | string | The userId to validate against. |
| onBehalfId | string | The onBehalfId to validate against. |
validation-helper~validateLocalLinkNetworkId(localLinkNetworkId, networkAddress, publicAddress) ⇒ string
The localLinkNetworkId is a base64 encoded object:
{
"networkAddress": (string),
"publicAddress": (string)
}Kind: inner method of validation-helper
Returns: string - The localLinkNetworkId.
Category: sync
Throws:
- Error If validation fails.
| Param | Type | Description |
|---|---|---|
| localLinkNetworkId | string | The id to validate. |
| networkAddress | string | A network address. |
| publicAddress | string | A public address. |
validation-helper~validateLocation(lon, lat, elevation, type) ⇒ object | null
Validate location.
Kind: inner method of validation-helper
Returns: object | null - The validated location object, or null if all values are missing.
Category: sync
Throws:
- Error If validation fails.
| Param | Type | Description |
|---|---|---|
| lon | number | Longitude (-180, 180) in degrees. |
| lat | number | Latitude (-90, 90) in degrees. |
| elevation | number | Elevation (-5000, 50000) in meters. |
| type | string | Type of coordinates ("Point"). |
validation-helper~validateGeoLocation(location) ⇒ object | null
Validate GeoLocation.
Kind: inner method of validation-helper
Returns: object | null - The validated location, or null if not present.
Category: sync
Throws:
- Error If validation fails.
| Param | Type | Description |
|---|---|---|
| location | object | null | A GeoJSON location object. |
validation-helper~validateUniqueAttributes(attributes) ⇒ boolean
Validate unique attributes.
Kind: inner method of validation-helper
Returns: boolean - True if attributes are unique by name.
Category: sync
| Param | Type | Description |
|---|---|---|
| attributes | Array.<object> | An array of attributes with a name property. |