Skip to main content

Data-Mate Functions

CATEGORY: Boolean

isBoolean

Type: FIELD_VALIDATION

Returns the input if it is a boolean, otherwise returns null

Examples

# Example (1)

isBoolean()
Input:
'TRUE'
Output:
null

# Example (2)

isBoolean()
Input:
false
Output:
false

# Example (3)

isBoolean()
Input:
1
Output:
null

# Example (4)

isBoolean()
Input:
102
Output:
null

# Example (5)

isBoolean()
Input:
'example'
Output:
null

isBooleanLike

Type: FIELD_VALIDATION

Returns the input if it can be converted to a boolean, otherwise returns null

Examples

# Example (1)

isBooleanLike()
Input:
'TRUE'
Output:
'TRUE'

# Example (2)

isBooleanLike()
Input:
'false'
Output:
'false'

# Example (3)

isBooleanLike()
Input:
1
Output:
1

# Example (4)

isBooleanLike()
Input:
102
Output:
null

# Example (5)

isBooleanLike()
Input:
'example'
Output:
null

toBoolean

Type: FIELD_TRANSFORM

Converts the input into a boolean and returns the boolean value

Examples

# Example (1)

toBoolean()
Input:
'TRUE'
Output:
true

# Example (2)

toBoolean()
Input:
1
Output:
true

# Example (3)

toBoolean()
Input:
0
Output:
false

# Example (4)

toBoolean()
Input:
null
Output:
null

CATEGORY: Geo

geoContains

Type: FIELD_VALIDATION

Returns the input if it contains the value argument, otherwise returns null. The interiors of both geo entities must intersect, and the argument geo-entity must not exceed the bounds of the input geo-entity

Arguments

  • value: (required) Any - The geo value used to check if it is contained by the input

Accepts

  • GeoJSON
  • GeoPoint
  • Geo
  • Object
  • String
  • Number

Examples

# Example (1)

geoContains({ value: '33.435518,-111.873616' })
Input:
'33.435518,-111.873616'
Output:
'33.435518,-111.873616'

# Example (2)

geoContains({ value: { type: 'Point', coordinates: [ -111.873616, 33.435518 ] } })
Input:
'45.518,-21.816'
Output:
null

# Example (3)

geoContains({ value: [ '10,10', '10,50', '50,50', '50,10', '10,10' ] })
Input:
{
type: 'Polygon',
coordinates: [ [ [ 0, 0 ], [ 100, 0 ], [ 100, 60 ], [ 0, 60 ], [ 0, 0 ] ] ]
}
Output:
{
type: 'Polygon',
coordinates: [ [ [ 0, 0 ], [ 100, 0 ], [ 100, 60 ], [ 0, 60 ], [ 0, 0 ] ] ]
}

# Example (4)

geoContains({
value: {
type: 'MultiPolygon',
coordinates: [
[
[ [ 10, 10 ], [ 10, 50 ], [ 50, 50 ], [ 50, 10 ], [ 10, 10 ] ]
],
[
[
[ -10, -10 ],
[ -10, -50 ],
[ -50, -50 ],
[ -50, -10 ],
[ -10, -10 ]
]
]
]
}
})
Input:
{
type: 'MultiPolygon',
coordinates: [
[ [ [ 10, 10 ], [ 10, 50 ], [ 50, 50 ], [ 50, 10 ], [ 10, 10 ] ] ],
[
[
[ -10, -10 ],
[ -10, -50 ],
[ -50, -50 ],
[ -50, -10 ],
[ -10, -10 ]
]
]
]
}
Output:
{
type: 'MultiPolygon',
coordinates: [
[ [ [ 10, 10 ], [ 10, 50 ], [ 50, 50 ], [ 50, 10 ], [ 10, 10 ] ] ],
[
[
[ -10, -10 ],
[ -10, -50 ],
[ -50, -50 ],
[ -50, -10 ],
[ -10, -10 ]
]
]
]
}

# Example (5)

geoContains({ value: { type: 'Point', coordinates: [ -30, -30 ] } })
Input:
{
type: 'MultiPolygon',
coordinates: [
[ [ [ 10, 10 ], [ 10, 20 ], [ 20, 20 ], [ 20, 10 ], [ 10, 10 ] ] ],
[ [ [ 30, 30 ], [ 30, 40 ], [ 40, 40 ], [ 40, 30 ], [ 30, 30 ] ] ]
]
}
Output:
null

geoPointWithinRange

Type: FIELD_VALIDATION Aliases: geoDistance

Returns the input if it's distance to the args point is less then or equal to the args distance

Arguments

  • point: (required) Any - The geo-point used as the center of the geo circle

  • distance: (required) String - Value of the radius of the geo-circle. It combines the number and the unit of measurement (ie 110km, 20in, 100yards). Possible units are as follows: mi, miles, mile, NM, nmi, nauticalmile, nauticalmiles, in, inch, inches, yd, yard, yards, m, meter, meters, km, kilometer, kilometers, mm, millimeter, millimeters, cm, centimeter, centimeters, ft and feet

Accepts

  • GeoJSON
  • GeoPoint
  • Geo
  • Object
  • String
  • Number

Examples

# Example (1)

geoPointWithinRange({ point: '33.435518,-111.873616', distance: '5000m' })
Input:
'33.435967,-111.867710'
Output:
'33.435967,-111.867710'

# Example (2)

geoPointWithinRange({ point: '33.435518,-111.873616', distance: '5000m' })
Input:
'22.435967,-150.867710'
Output:
null

geoDisjoint

Type: FIELD_VALIDATION

Returns the input if it does not have any intersection (overlap) with the argument value, otherwise returns null

Arguments

  • value: (required) Any - The geo value used to validate that no intersection exists with the input geo-entity

Accepts

  • GeoJSON
  • GeoPoint
  • Geo
  • Object
  • String
  • Number

Examples

# Example (1)

geoDisjoint({ value: [ '10,10', '10,50', '50,50', '50,10', '10,10' ] })
Input:
'-33.435967,-111.867710'
Output:
'-33.435967,-111.867710'

# Example (2)

geoDisjoint({ value: [ '10,10', '10,50', '50,50', '50,10', '10,10' ] })
Input:
{ type: 'Point', coordinates: [ 20, 20 ] }
Output:
null

# Example (3)

geoDisjoint({
value: {
type: 'Polygon',
coordinates: [ [ [ 0, 0 ], [ 0, 15 ], [ 15, 15 ], [ 15, 0 ], [ 0, 0 ] ] ]
}
})
Input:
{
type: 'Polygon',
coordinates: [ [ [ 20, 20 ], [ 20, 30 ], [ 30, 30 ], [ 30, 20 ], [ 20, 20 ] ] ]
}
Output:
{
type: 'Polygon',
coordinates: [ [ [ 20, 20 ], [ 20, 30 ], [ 30, 30 ], [ 30, 20 ], [ 20, 20 ] ] ]
}

# Example (4)

geoDisjoint({
value: {
type: 'Polygon',
coordinates: [ [ [ 0, 0 ], [ 0, 15 ], [ 15, 15 ], [ 15, 0 ], [ 0, 0 ] ] ]
}
})
Input:
{
type: 'MultiPolygon',
coordinates: [
[ [ [ 10, 10 ], [ 10, 50 ], [ 50, 50 ], [ 50, 10 ], [ 10, 10 ] ] ],
[
[
[ -10, -10 ],
[ -10, -50 ],
[ -50, -50 ],
[ -50, -10 ],
[ -10, -10 ]
]
]
]
}
Output:
null

geoIntersects

Type: FIELD_VALIDATION

Returns the input if it has at least one point in common with the argument value, otherwise returns null

Arguments

  • value: (required) Any - The geo value used to compare with the input geo-entity

Accepts

  • GeoJSON
  • GeoPoint
  • Geo
  • Object
  • String
  • Number

Examples

# Example (1)

geoIntersects({ value: [ '10,10', '10,50', '50,50', '50,10', '10,10' ] })
Input:
{ type: 'Point', coordinates: [ 20, 20 ] }
Output:
{ type: 'Point', coordinates: [ 20, 20 ] }

# Example (2)

geoIntersects({ value: [ '10,10', '10,50', '50,50', '50,10', '10,10' ] })
Input:
{
type: 'Polygon',
coordinates: [ [ [ 0, 0 ], [ 0, 15 ], [ 15, 15 ], [ 15, 0 ], [ 0, 0 ] ] ]
}
Output:
{
type: 'Polygon',
coordinates: [ [ [ 0, 0 ], [ 0, 15 ], [ 15, 15 ], [ 15, 0 ], [ 0, 0 ] ] ]
}

# Example (3)

geoIntersects({
value: {
type: 'Polygon',
coordinates: [ [ [ 0, 0 ], [ 0, 15 ], [ 15, 15 ], [ 15, 0 ], [ 0, 0 ] ] ]
}
})
Input:
{
type: 'MultiPolygon',
coordinates: [
[ [ [ 10, 10 ], [ 10, 50 ], [ 50, 50 ], [ 50, 10 ], [ 10, 10 ] ] ],
[
[
[ -10, -10 ],
[ -10, -50 ],
[ -50, -50 ],
[ -50, -10 ],
[ -10, -10 ]
]
]
]
}
Output:
{
type: 'MultiPolygon',
coordinates: [
[ [ [ 10, 10 ], [ 10, 50 ], [ 50, 50 ], [ 50, 10 ], [ 10, 10 ] ] ],
[
[
[ -10, -10 ],
[ -10, -50 ],
[ -50, -50 ],
[ -50, -10 ],
[ -10, -10 ]
]
]
]
}

geoRelation

Type: FIELD_VALIDATION

Returns the input if it relates, as specified in the relation argument, to the argument value (defaults to "within"), otherwise returns null

Arguments

  • value: (required) Any - The geo value used to compare to the input geo-entity

  • relation: String - How the geo input should relate the argument value, defaults to "within" : intersects, disjoint, within and contains

Accepts

  • GeoJSON
  • GeoPoint
  • Geo
  • Object
  • String
  • Number

Examples

# Example (1)

geoRelation({ value: [ '10,10', '10,50', '50,50', '50,10', '10,10' ] })
Input:
'20,20'
Output:
'20,20'

# Example (2)

geoRelation({
value: [ '10,10', '10,50', '50,50', '50,10', '10,10' ],
relation: 'within'
})
Input:
'20,20'
Output:
'20,20'

# Example (3)

geoRelation({
value: [ '10,10', '10,50', '50,50', '50,10', '10,10' ],
relation: 'contains'
})
Input:
'20,20'
Output:
null

# Example (4)

geoRelation({
value: {
type: 'Polygon',
coordinates: [ [ [ 0, 0 ], [ 0, 15 ], [ 15, 15 ], [ 15, 0 ], [ 0, 0 ] ] ]
},
relation: 'disjoint'
})
Input:
{
type: 'Polygon',
coordinates: [ [ [ 20, 20 ], [ 20, 30 ], [ 30, 30 ], [ 30, 20 ], [ 20, 20 ] ] ]
}
Output:
{
type: 'Polygon',
coordinates: [ [ [ 20, 20 ], [ 20, 30 ], [ 30, 30 ], [ 30, 20 ], [ 20, 20 ] ] ]
}

# Example (5)

geoRelation({
value: [ '10,10', '10,50', '50,50', '50,10', '10,10' ],
relation: 'intersects'
})
Input:
{
type: 'Polygon',
coordinates: [ [ [ 0, 0 ], [ 0, 15 ], [ 15, 15 ], [ 15, 0 ], [ 0, 0 ] ] ]
}
Output:
{
type: 'Polygon',
coordinates: [ [ [ 0, 0 ], [ 0, 15 ], [ 15, 15 ], [ 15, 0 ], [ 0, 0 ] ] ]
}

# Example (6)

geoRelation({
value: [ '10,10', '10,50', '50,50', '50,10', '10,10' ],
relation: 'disjoint'
})
Input:
{
type: 'Polygon',
coordinates: [ [ [ 0, 0 ], [ 0, 15 ], [ 15, 15 ], [ 15, 0 ], [ 0, 0 ] ] ]
}
Output:
null

geoWithin

Type: FIELD_VALIDATION

Returns the input if it is completely within the argument geo-value. The interiors of both geo entities must intersect and the geo data must not exceed the bounds of the geo argument. Otherwise returns null

Arguments

  • value: (required) Any - The geo value used to compare the input value to

Accepts

  • GeoJSON
  • GeoPoint
  • Geo
  • Object
  • String
  • Number

Examples

# Example (1)

geoWithin({ value: [ '10,10', '10,50', '50,50', '50,10', '10,10' ] })
Input:
{ type: 'Point', coordinates: [ 20, 20 ] }
Output:
{ type: 'Point', coordinates: [ 20, 20 ] }

# Example (2)

geoWithin({ value: [ '10,10', '10,50', '50,50', '50,10', '10,10' ] })
Input:
'20,20'
Output:
'20,20'

# Example (3)

geoWithin({ value: [ '10,10', '10,50', '50,50', '50,10', '10,10' ] })
Input:
{
type: 'Polygon',
coordinates: [ [ [ 20, 20 ], [ 20, 30 ], [ 30, 30 ], [ 30, 20 ], [ 20, 20 ] ] ]
}
Output:
{
type: 'Polygon',
coordinates: [ [ [ 20, 20 ], [ 20, 30 ], [ 30, 30 ], [ 30, 20 ], [ 20, 20 ] ] ]
}

# Example (4)

geoWithin({
value: {
type: 'MultiPolygon',
coordinates: [
[
[ [ 10, 10 ], [ 10, 50 ], [ 50, 50 ], [ 50, 10 ], [ 10, 10 ] ]
],
[
[
[ -10, -10 ],
[ -10, -50 ],
[ -50, -50 ],
[ -50, -10 ],
[ -10, -10 ]
]
]
]
}
})
Input:
{
type: 'MultiPolygon',
coordinates: [
[ [ [ 10, 10 ], [ 10, 50 ], [ 50, 50 ], [ 50, 10 ], [ 10, 10 ] ] ],
[
[
[ -10, -10 ],
[ -10, -50 ],
[ -50, -50 ],
[ -50, -10 ],
[ -10, -10 ]
]
]
]
}
Output:
{
type: 'MultiPolygon',
coordinates: [
[ [ [ 10, 10 ], [ 10, 50 ], [ 50, 50 ], [ 50, 10 ], [ 10, 10 ] ] ],
[
[
[ -10, -10 ],
[ -10, -50 ],
[ -50, -50 ],
[ -50, -10 ],
[ -10, -10 ]
]
]
]
}

# Example (5)

geoWithin({
value: {
type: 'MultiPolygon',
coordinates: [
[
[ [ 10, 10 ], [ 10, 50 ], [ 50, 50 ], [ 50, 10 ], [ 10, 10 ] ]
],
[
[
[ -10, -10 ],
[ -10, -50 ],
[ -50, -50 ],
[ -50, -10 ],
[ -10, -10 ]
]
]
]
}
})
Input:
{
type: 'MultiPolygon',
coordinates: [
[ [ [ 10, 10 ], [ 10, 20 ], [ 20, 20 ], [ 20, 10 ], [ 10, 10 ] ] ],
[ [ [ 30, 30 ], [ 30, 40 ], [ 40, 40 ], [ 40, 30 ], [ 30, 30 ] ] ]
]
}
Output:
{
type: 'MultiPolygon',
coordinates: [
[ [ [ 10, 10 ], [ 10, 20 ], [ 20, 20 ], [ 20, 10 ], [ 10, 10 ] ] ],
[ [ [ 30, 30 ], [ 30, 40 ], [ 40, 40 ], [ 40, 30 ], [ 30, 30 ] ] ]
]
}

geoContainsPoint

Type: FIELD_VALIDATION

Returns the input if it contains the geo-point, otherwise returns null

Arguments

  • point: (required) Any - The point used to see if it is within the input geo-shape. If the input geo-shape is a point, it checks if they are the same

Accepts

  • GeoJSON

Examples

# Example (1)

geoContainsPoint({ point: '15, 15' })
Input:
{
type: 'Polygon',
coordinates: [ [ [ 10, 10 ], [ 10, 50 ], [ 50, 50 ], [ 50, 10 ], [ 10, 10 ] ] ]
}
Output:
{
type: 'Polygon',
coordinates: [ [ [ 10, 10 ], [ 10, 50 ], [ 50, 50 ], [ 50, 10 ], [ 10, 10 ] ] ]
}

# Example (2)

geoContainsPoint({ point: '15, 15' })
Input:
{
type: 'MultiPolygon',
coordinates: [
[ [ [ 10, 10 ], [ 10, 50 ], [ 50, 50 ], [ 50, 10 ], [ 10, 10 ] ] ],
[
[
[ -10, -10 ],
[ -10, -50 ],
[ -50, -50 ],
[ -50, -10 ],
[ -10, -10 ]
]
]
]
}
Output:
{
type: 'MultiPolygon',
coordinates: [
[ [ [ 10, 10 ], [ 10, 50 ], [ 50, 50 ], [ 50, 10 ], [ 10, 10 ] ] ],
[
[
[ -10, -10 ],
[ -10, -50 ],
[ -50, -50 ],
[ -50, -10 ],
[ -10, -10 ]
]
]
]
}

# Example (3)

geoContainsPoint({ point: '15, 15' })
Input:
{
type: 'Polygon',
coordinates: [
[
[ -10, -10 ],
[ -10, -50 ],
[ -50, -50 ],
[ -50, -10 ],
[ -10, -10 ]
],
[
[ -20, -20 ],
[ -20, -40 ],
[ -40, -40 ],
[ -40, -20 ],
[ -20, -20 ]
]
]
}
Output:
null

Point is within a polygon with holes

# Example (4)

geoContainsPoint({ point: '15, 15' })
Input:
{
type: 'Polygon',
coordinates: [
[ [ 10, 10 ], [ 10, 50 ], [ 50, 50 ], [ 50, 10 ], [ 10, 10 ] ],
[ [ 20, 20 ], [ 20, 40 ], [ 40, 40 ], [ 40, 20 ], [ 20, 20 ] ]
]
}
Output:
{
type: 'Polygon',
coordinates: [
[ [ 10, 10 ], [ 10, 50 ], [ 50, 50 ], [ 50, 10 ], [ 10, 10 ] ],
[ [ 20, 20 ], [ 20, 40 ], [ 40, 40 ], [ 40, 20 ], [ 20, 20 ] ]
]
}

Point can match against a geo-shape point

# Example (5)

geoContainsPoint({ point: '15, 15' })
Input:
{ type: 'Point', coordinates: [ 15, 15 ] }
Output:
{ type: 'Point', coordinates: [ 15, 15 ] }

inGeoBoundingBox

Type: FIELD_VALIDATION Aliases: geoBox

Returns the input if it is within the geo bounding box, otherwise returns null

Arguments

  • top_left: (required) Any - The top-left geo-point used to construct the geo bounding box, must be a valid geo-point input

  • bottom_right: (required) Any - The bottom_right geo-point used to construct the geo bounding box, must be a valid geo-point input

Accepts

  • GeoJSON
  • GeoPoint
  • Geo
  • Object
  • String
  • Number

Examples

# Example (1)

inGeoBoundingBox({
top_left: '33.906320,-112.758421',
bottom_right: '32.813646,-111.058902'
})
Input:
'33.2,-112.3'
Output:
'33.2,-112.3'

# Example (2)

inGeoBoundingBox({
top_left: '33.906320,-112.758421',
bottom_right: '32.813646,-111.058902'
})
Input:
'43,-132'
Output:
null

# Example (3)

inGeoBoundingBox({
top_left: '33.906320,-112.758421',
bottom_right: '32.813646,-111.058902'
})
Input:
{ type: 'Point', coordinates: [ -112, 33 ] }
Output:
{ type: 'Point', coordinates: [ -112, 33 ] }

isGeoJSON

Type: FIELD_VALIDATION

Returns the input if it is a GeoJSON object, otherwise returns null

Accepts

  • GeoJSON
  • Object

Examples

# Example (1)

isGeoJSON()
Input:
'60,40'
Output:
null

# Example (2)

isGeoJSON()
Input:
{ lat: 60, lon: 40 }
Output:
null

# Example (3)

isGeoJSON()
Input:
{ type: 'Point', coordinates: [ 12, 12 ] }
Output:
{ type: 'Point', coordinates: [ 12, 12 ] }

# Example (4)

isGeoJSON()
Input:
{
type: 'Polygon',
coordinates: [ [ [ 0, 0 ], [ 0, 15 ], [ 15, 15 ], [ 15, 0 ], [ 0, 0 ] ] ]
}
Output:
{
type: 'Polygon',
coordinates: [ [ [ 0, 0 ], [ 0, 15 ], [ 15, 15 ], [ 15, 0 ], [ 0, 0 ] ] ]
}

# Example (5)

isGeoJSON()
Input:
{
type: 'MultiPolygon',
coordinates: [
[ [ [ 10, 10 ], [ 10, 50 ], [ 50, 50 ], [ 50, 10 ], [ 10, 10 ] ] ],
[
[
[ -10, -10 ],
[ -10, -50 ],
[ -50, -50 ],
[ -50, -10 ],
[ -10, -10 ]
]
]
]
}
Output:
{
type: 'MultiPolygon',
coordinates: [
[ [ [ 10, 10 ], [ 10, 50 ], [ 50, 50 ], [ 50, 10 ], [ 10, 10 ] ] ],
[
[
[ -10, -10 ],
[ -10, -50 ],
[ -50, -50 ],
[ -50, -10 ],
[ -10, -10 ]
]
]
]
}

isGeoPoint

Type: FIELD_VALIDATION

Returns the input if it is parsable to a geo-point, otherwise returns null

Examples

# Example (1)

isGeoPoint()
Input:
'60,40'
Output:
'60,40'

# Example (2)

isGeoPoint()
Input:
[ 60, 40 ]
Output:
[ 60, 40 ]

# Example (3)

isGeoPoint()
Input:
{ lat: 60, lon: 40 }
Output:
{ lat: 60, lon: 40 }

# Example (4)

isGeoPoint()
Input:
{ latitude: 60, longitude: 40 }
Output:
{ latitude: 60, longitude: 40 }

# Example (5)

isGeoPoint()
Input:
'something'
Output:
null

isGeoShapeMultiPolygon

Type: FIELD_VALIDATION

Returns the input if it is a valid geo-json multi-polygon, otherwise returns null

Accepts

  • GeoJSON
  • Object

Examples

# Example (1)

isGeoShapeMultiPolygon()
Input:
{ type: 'Point', coordinates: [ 12, 12 ] }
Output:
null

# Example (2)

isGeoShapeMultiPolygon()
Input:
{
type: 'Polygon',
coordinates: [ [ [ 10, 10 ], [ 10, 50 ], [ 50, 50 ], [ 50, 10 ], [ 10, 10 ] ] ]
}
Output:
null

# Example (3)

isGeoShapeMultiPolygon()
Input:
{
type: 'MultiPolygon',
coordinates: [
[ [ [ 10, 10 ], [ 10, 50 ], [ 50, 50 ], [ 50, 10 ], [ 10, 10 ] ] ],
[
[
[ -10, -10 ],
[ -10, -50 ],
[ -50, -50 ],
[ -50, -10 ],
[ -10, -10 ]
]
]
]
}
Output:
{
type: 'MultiPolygon',
coordinates: [
[ [ [ 10, 10 ], [ 10, 50 ], [ 50, 50 ], [ 50, 10 ], [ 10, 10 ] ] ],
[
[
[ -10, -10 ],
[ -10, -50 ],
[ -50, -50 ],
[ -50, -10 ],
[ -10, -10 ]
]
]
]
}

isGeoShapePoint

Type: FIELD_VALIDATION

Returns the input if it is a valid geo-json point, otherwise returns null

Accepts

  • GeoJSON
  • Object

Examples

# Example (1)

isGeoShapePoint()
Input:
{ type: 'Point', coordinates: [ 12, 12 ] }
Output:
{ type: 'Point', coordinates: [ 12, 12 ] }

# Example (2)

isGeoShapePoint()
Input:
{
type: 'Polygon',
coordinates: [ [ [ 10, 10 ], [ 10, 50 ], [ 50, 50 ], [ 50, 10 ], [ 10, 10 ] ] ]
}
Output:
null

# Example (3)

isGeoShapePoint()
Input:
{
type: 'MultiPolygon',
coordinates: [
[ [ [ 10, 10 ], [ 10, 50 ], [ 50, 50 ], [ 50, 10 ], [ 10, 10 ] ] ],
[
[
[ -10, -10 ],
[ -10, -50 ],
[ -50, -50 ],
[ -50, -10 ],
[ -10, -10 ]
]
]
]
}
Output:
null

isGeoShapePolygon

Type: FIELD_VALIDATION

Return the input if it is a valid geo-json polygon, otherwise returns null

Accepts

  • GeoJSON
  • Object

Examples

# Example (1)

isGeoShapePolygon()
Input:
{ type: 'Point', coordinates: [ 12, 12 ] }
Output:
null

# Example (2)

isGeoShapePolygon()
Input:
{
type: 'Polygon',
coordinates: [ [ [ 10, 10 ], [ 10, 50 ], [ 50, 50 ], [ 50, 10 ], [ 10, 10 ] ] ]
}
Output:
{
type: 'Polygon',
coordinates: [ [ [ 10, 10 ], [ 10, 50 ], [ 50, 50 ], [ 50, 10 ], [ 10, 10 ] ] ]
}

# Example (3)

isGeoShapePolygon()
Input:
{
type: 'MultiPolygon',
coordinates: [
[ [ [ 10, 10 ], [ 10, 50 ], [ 50, 50 ], [ 50, 10 ], [ 10, 10 ] ] ],
[
[
[ -10, -10 ],
[ -10, -50 ],
[ -50, -50 ],
[ -50, -10 ],
[ -10, -10 ]
]
]
]
}
Output:
null

toGeoJSON

Type: FIELD_TRANSFORM

Converts a geo-point or a list of geo-points to geoJSON. Only supports geoJSON points or simple polygons, there is currently no support for multi-polygons or polygons/ multipolygons with holes

Accepts

  • String
  • Object
  • GeoPoint
  • Geo
  • Number
  • GeoJSON

Examples

# Example (1)

toGeoJSON()
Input:
'60,40'
Output:
{ type: 'Point', coordinates: [ 40, 60 ] }

# Example (2)

toGeoJSON()
Input:
[ '10,10', '10,50', '50,50', '50,10', '10,10' ]
Output:
{
type: 'Polygon',
coordinates: [ [ [ 10, 10 ], [ 50, 10 ], [ 50, 50 ], [ 10, 50 ], [ 10, 10 ] ] ]
}

# Example (3)

toGeoJSON()
Input:
{
type: 'MultiPolygon',
coordinates: [
[ [ [ 10, 10 ], [ 10, 50 ], [ 50, 50 ], [ 50, 10 ], [ 10, 10 ] ] ],
[
[
[ -10, -10 ],
[ -10, -50 ],
[ -50, -50 ],
[ -50, -10 ],
[ -10, -10 ]
]
]
]
}
Output:
{
type: 'MultiPolygon',
coordinates: [
[ [ [ 10, 10 ], [ 10, 50 ], [ 50, 50 ], [ 50, 10 ], [ 10, 10 ] ] ],
[
[
[ -10, -10 ],
[ -10, -50 ],
[ -50, -50 ],
[ -50, -10 ],
[ -10, -10 ]
]
]
]
}

toGeoPoint

Type: FIELD_TRANSFORM

Converts the input to a geo-point

Accepts

  • String
  • Object
  • GeoPoint
  • Geo
  • Number
  • Float

Examples

# Example (1)

toGeoPoint()
Input:
'60,40'
Output:
{ lon: 40, lat: 60 }

# Example (2)

toGeoPoint()
Input:
{ latitude: 40, longitude: 60 }
Output:
{ lon: 60, lat: 40 }

# Example (3)

toGeoPoint()
Input:
[ 50, 60 ]
Output:
{ lon: 50, lat: 60 }

# Example (4)

toGeoPoint()
Input:
'not an geo point'
Throws

CATEGORY: JSON

cast

Type: FIELD_TRANSFORM

Converts the field to another type, this is also useful changing the metadata of field

Arguments

  • type: (required) String - The type of field, defaults to Any, you may need to specify the type for better execution optimization

  • array: Boolean - Indicates whether the field is an array

  • description: Text - Set the description for the field

  • locale: String - Specify the locale for the field (only compatible with some field types). Must be a BCP 47 Language Tag

  • indexed: Boolean - Specifies whether the field is indexed in elasticsearch (Only type Object currently support this)

  • format: String - The format for the field. Currently only supported by Date fields

  • is_primary_date: Boolean - Used to denote naming of timeseries indices, and if any search/join queries off of this field should use a date searching algorithm

  • time_resolution: String - Indicates whether the data has second or millisecond resolutions used with the is_primary_date

  • child_config: Object - If parsing an object, you can specify the DataTypeFields of the key/values of the object. This is an object whose keys are the name of the fields, whose value is an object with all of the other properties listed above (ie type, array, locale, format but not child_config)

Examples

# Example (1)

cast({ type: 'Integer' })
Input:
'21.223'
Output:
21

# Example (2)

cast({ type: 'Integer', array: true })
Input:
'21.223'
Output:
[ 21 ]

# Example (3)

cast({ type: 'Object', child_config: { foo: { type: 'Integer' } } })
Input:
{ foo: '21.23' }
Output:
{ foo: 21 }

parseJSON

Type: FIELD_TRANSFORM

Parses a JSON string and returns the value or object according to the arg options

Accepts

  • String

setDefault

Type: FIELD_TRANSFORM

Replaces missing values in a column with a constant value

Arguments

  • value: (required) Any - The default value to use

Examples

# Example (1)

setDefault({ value: 'example' })
Input:
null
Output:
'example'

# Example (2)

setDefault({ value: 'example' })
Input:
null
Output:
[ 'example' ]

toJSON

Type: FIELD_TRANSFORM

Converts whole input to JSON format

Examples

# Example (1)

toJSON()
Input:
278218429446951548637196401n
Output:
'278218429446951548637196400'

# Example (2)

toJSON()
Input:
false
Output:
'false'

# Example (3)

toJSON()
Input:
{ some: 1234 }
Output:
'{"some":1234}'

# Example (4)

toJSON()
Input:
{ bigNum: 278218429446951548637196401n }
Output:
'{"bigNum":"278218429446951548637196400"}'

CATEGORY: Date

addToDate

Type: FIELD_TRANSFORM

Returns the input date added to a date expression or a specific number of years, months, weeks, days, hours, minutes, seconds, or milliseconds

Arguments

  • expr: String - The date math expression used to add to the input date. For example, 1h or 1h+2m

  • years: Integer - The number of years to add to the date. This cannot be specified with expr

  • months: Integer - The number of months to add to the date. This cannot be specified with expr

  • weeks: Integer - The number of weeks to add to the date. This cannot be specified with expr

  • days: Integer - The number of days to add to the date. This cannot be specified with expr

  • hours: Integer - The number of hours to add to the date. This cannot be specified with expr

  • minutes: Integer - The number of minutes to add to the date. This cannot be specified with expr

  • seconds: Integer - The number of seconds to add to the date. This cannot be specified with expr

  • milliseconds: Integer - The number of milliseconds to add to the date. This cannot be specified with expr

Accepts

  • Date
  • String
  • Number

Examples

# Example (1)

addToDate({ expr: '10h+2m' })
Input:
'2019-10-22T22:00:00.000Z'
Output:
'2019-10-23T08:02:00.000Z'

# Example (2)

addToDate({ months: 1, minutes: 2 })
Input:
'2019-10-22T22:00:00.000Z'
Output:
'2019-11-22T22:02:00.000Z'

# Example (3)

addToDate()
Input:
'2019-10-22T22:00:00.000Z'

Throws: Expected an expr or years, months, weeks, days, hours, minutes, seconds or milliseconds

# Example (4)

addToDate({ expr: '1hr', months: 10 })
Input:
'2019-10-22T22:00:00.000Z'

Throws: Invalid use of months with expr parameter

formatDate

Type: FIELD_TRANSFORM

Converts a date value to a formatted date string. Can specify the format with args to format the output value

Arguments

  • format: String - When the value is a string, this indicates the date string format. See https://date-fns.org/v2.16.1/docs/parse for more info. Default: iso_8601 for strings and epoch_millis for numbers

Accepts

  • Date
  • String
  • Number

Examples

# Example (1)

formatDate({ format: 'yyyy-MM-dd' })
Input:
'2019-10-22T00:00:00.000Z'
Output:
'2019-10-22'

# Example (2)

formatDate()
Input:
102390933
Output:
'1970-01-02T04:26:30.933Z'

# Example (3)

formatDate({ format: 'milliseconds' })
Input:
'1973-03-31T01:55:33.000Z'
Output:
102390933000

# Example (4)

formatDate()
Input:
'2001-01-01T01:00:00.000Z'
Output:
'2001-01-01T01:00:00.000Z'

getDate

Type: FIELD_TRANSFORM

Returns the day of the month of the input date in UTC Time

Accepts

  • Date
  • String
  • Number

Examples

# Example (1)

getDate()
Input:
'2021-05-11T10:12:41.091Z'
Output:
11

# Example (2)

getDate()
Input:
2021-05-16T10:59:19.091Z
Output:
16

# Example (3)

getDate()
Input:
'05/22/2021 EST'
Output:
22

# Example (4)

getDate()
Input:
1510123223231
Output:
8

getHours

Type: FIELD_TRANSFORM

Returns the hours of the input date in UTC Time

Accepts

  • Date
  • String
  • Number

Examples

# Example (1)

getHours()
Input:
'2021-05-10T10:12:41.091Z'
Output:
10

# Example (2)

getHours()
Input:
2021-05-10T10:59:19.091Z
Output:
10

# Example (3)

getHours()
Input:
'05/22/2021 EST'
Output:
5

# Example (4)

getHours()
Input:
17154123223231
Output:
2

getMilliseconds

Type: FIELD_TRANSFORM

Returns the milliseconds of the input date

Accepts

  • Date
  • String
  • Number

Examples

# Example (1)

getMilliseconds()
Input:
'2021-05-10T10:00:01.091Z'
Output:
91

# Example (2)

getMilliseconds()
Input:
2021-05-10T10:00:01.091Z
Output:
91

# Example (3)

getMilliseconds()
Input:
1715472000231
Output:
231

getMinutes

Type: FIELD_TRANSFORM

Returns the minutes of the input date in UTC time

Accepts

  • Date
  • String
  • Number

Examples

# Example (1)

getMinutes()
Input:
'2021-05-10T10:12:41.091Z'
Output:
12

# Example (2)

getMinutes()
Input:
2021-05-10T10:59:19.091Z
Output:
59

# Example (3)

getMinutes()
Input:
1715472323231
Output:
5

getMonth

Type: FIELD_TRANSFORM

Returns the month of the input date in UTC Time

Accepts

  • Date
  • String
  • Number

Examples

# Example (1)

getMonth()
Input:
'2021-05-11T10:12:41.091Z'
Output:
5

# Example (2)

getMonth()
Input:
2021-05-16T10:59:19.091Z
Output:
5

# Example (3)

getMonth()
Input:
'05/22/2021 EST'
Output:
5

# Example (4)

getMonth()
Input:
1510123223231
Output:
11

getSeconds

Type: FIELD_TRANSFORM

Returns the seconds of the input date

Accepts

  • Date
  • String
  • Number

Examples

# Example (1)

getSeconds()
Input:
'2021-05-10T10:00:41.091Z'
Output:
41

# Example (2)

getSeconds()
Input:
2021-05-10T10:00:19.091Z
Output:
19

# Example (3)

getSeconds()
Input:
1715472323231
Output:
23

getTimeBetween

Type: FIELD_TRANSFORM

Returns the time duration between the input value and start or end arg. Can also select the interval and format with the args interval option

Arguments

  • start: Date - Start time of time range, if start is after the input it will return a negative number

  • end: Date - End time of time range, if end is before the input it will return a negative number

  • interval: (required) String - The interval of the return value. Accepts milliseconds, seconds, minutes, hours, days, calendarDays, businessDays, weeks, calendarWeeks, months, calendarMonths, quarters, calendarQuarters, years, calendarYears, calendarISOWeekYears and ISOWeekYears or use ISO8601 to get the return value in ISO-8601 duration format, see https://www.digi.com/resources/documentation/digidocs/90001437-13/reference/r_iso_8601_duration_format.htm

Accepts

  • Date
  • String
  • Number

Examples

# Example (1)

getTimeBetween({ start: '2021-05-10T10:00:00.000Z', interval: 'milliseconds' })
Input:
2021-05-10T10:00:01.000Z
Output:
1000

# Example (2)

getTimeBetween({ end: '2021-05-10T10:00:00.000Z', interval: 'days' })
Input:
'2021-05-09T10:00:00.000Z'
Output:
1

# Example (3)

getTimeBetween({ end: 1620764441001, interval: 'seconds' })
Input:
1620764440001
Output:
1

# Example (4)

getTimeBetween({ end: '2023-01-09T18:19:23.132Z', interval: 'ISO8601' })
Input:
'2021-05-10T10:00:00.000Z'
Output:
'P1Y7M30DT8H19M23S'

getTimezoneOffset

Type: FIELD_TRANSFORM

Given a date and timezone, it will return the offset from UTC in minutes. This is more accurate than timezoneToOffset as it can better account for daylight saving time

Arguments

  • timezone: (required) String - Must be a valid IANA time zone name

Accepts

  • String
  • Number
  • Date

Examples

# Example (1)

getTimezoneOffset({ timezone: 'Africa/Accra' })
Input:
2021-05-20T15:13:52.131Z
Output:
0

# Example (2)

getTimezoneOffset({ timezone: 'America/Anchorage' })
Input:
2021-05-20T15:13:52.131Z
Output:
-480

# Example (3)

getTimezoneOffset({ timezone: 'America/Aruba' })
Input:
2021-05-20T15:13:52.131Z
Output:
-240

# Example (4)

getTimezoneOffset({ timezone: 'Asia/Istanbul' })
Input:
2021-05-20T15:13:52.131Z
Output:
180

# Example (5)

getTimezoneOffset({ timezone: 'Australia/Canberra' })
Input:
2021-05-20T15:13:52.131Z
Output:
600

getYear

Type: FIELD_TRANSFORM

Returns the year of the input date in UTC Time

Accepts

  • Date
  • String
  • Number

Examples

# Example (1)

getYear()
Input:
'2021-05-11T10:12:41.091Z'
Output:
2021

# Example (2)

getYear()
Input:
2021-05-16T10:59:19.091Z
Output:
2021

# Example (3)

getYear()
Input:
'05/22/2021 EST'
Output:
2021

# Example (4)

getYear()
Input:
1510123223231
Output:
2017

lookupTimezone

Type: FIELD_TRANSFORM

Returns the timezone of a geo point's location

Accepts

  • String
  • Object
  • GeoPoint
  • Geo
  • Number
  • Float

Examples

# Example (1)

lookupTimezone()
Input:
'33.385765, -111.891167'
Output:
'America/Phoenix'

In ocean outside Morocco

# Example (2)

lookupTimezone()
Input:
'30.00123,-12.233'
Output:
'Etc/GMT+1'

# Example (3)

lookupTimezone()
Input:
[ 30.00123, 12.233 ]
Output:
'Africa/Khartoum'

# Example (4)

lookupTimezone()
Input:
{ lat: 48.86168702148502, lon: 2.3366209636711 }
Output:
'Europe/Paris'

setDate

Type: FIELD_TRANSFORM

Returns the input date with the day of the month set to the args value

Arguments

  • value: (required) Number - Value to set day of the month to, must be between 1 and 31

Accepts

  • String
  • Date
  • Number

Examples

# Example (1)

setDate({ value: 12 })
Input:
'2021-05-14T20:45:30.000Z'
Output:
'2021-05-12T20:45:30.000Z'

# Example (2)

setDate({ value: 22 })
Input:
2021-05-14T20:45:30.091Z
Output:
'2021-05-22T20:45:30.091Z'

# Example (3)

setDate({ value: 1 })
Input:
1715472000000
Output:
'2024-05-01T00:00:00.000Z'

setHours

Type: FIELD_TRANSFORM

Returns the input date with the hours set to the args value

Arguments

  • value: (required) Number - Value to set hours to, must be between 0 and 23

Accepts

  • String
  • Date
  • Number

Examples

# Example (1)

setHours({ value: 12 })
Input:
'2021-05-14T20:45:30.000Z'
Output:
'2021-05-14T12:45:30.000Z'

# Example (2)

setHours({ value: 22 })
Input:
2021-05-14T20:45:30.091Z
Output:
'2021-05-14T22:45:30.091Z'

# Example (3)

setHours({ value: 1 })
Input:
1715472000000
Output:
'2024-05-12T01:00:00.000Z'

setMilliseconds

Type: FIELD_TRANSFORM

Returns the input date with the milliseconds set to the args value

Arguments

  • value: (required) Number - Value to set milliseconds to, must be between 0 and 999

Accepts

  • String
  • Date
  • Number

Examples

# Example (1)

setMilliseconds({ value: 392 })
Input:
'2021-05-14T20:45:30.000Z'
Output:
'2021-05-14T20:45:30.392Z'

# Example (2)

setMilliseconds({ value: 483 })
Input:
2021-05-14T20:45:30.091Z
Output:
'2021-05-14T20:45:30.483Z'

# Example (3)

setMilliseconds({ value: 1 })
Input:
1715472000000
Output:
'2024-05-12T00:00:00.001Z'

setMinutes

Type: FIELD_TRANSFORM

Returns the input date with the minutes set to the args value

Arguments

  • value: (required) Number - Value to set minutes to, must be between 0 and 59

Accepts

  • String
  • Date
  • Number

Examples

# Example (1)

setMinutes({ value: 12 })
Input:
'2021-05-14T20:45:30.000Z'
Output:
'2021-05-14T20:12:30.000Z'

# Example (2)

setMinutes({ value: 22 })
Input:
2021-05-14T20:45:30.091Z
Output:
'2021-05-14T20:22:30.091Z'

# Example (3)

setMinutes({ value: 1 })
Input:
1715472000000
Output:
'2024-05-12T00:01:00.000Z'

setMonth

Type: FIELD_TRANSFORM

Returns the input date with the month set to the args value

Arguments

  • value: (required) Number - Value to set value to, must be between 1 and 12

Accepts

  • String
  • Date
  • Number

Examples

# Example (1)

setMonth({ value: 12 })
Input:
'2021-05-14T20:45:30.000Z'
Output:
'2021-12-14T20:45:30.000Z'

# Example (2)

setMonth({ value: 2 })
Input:
2021-05-14T20:45:30.091Z
Output:
'2021-02-14T20:45:30.091Z'

# Example (3)

setMonth({ value: 1 })
Input:
1715472000000
Output:
'2024-01-12T00:00:00.000Z'

setSeconds

Type: FIELD_TRANSFORM

Returns the input date with the seconds set to the args value

Arguments

  • value: (required) Number - Value to set seconds to, must be between 0 and 59

Accepts

  • String
  • Date
  • Number

Examples

# Example (1)

setSeconds({ value: 12 })
Input:
'2021-05-14T20:45:30.000Z'
Output:
'2021-05-14T20:45:12.000Z'

# Example (2)

setSeconds({ value: 22 })
Input:
2021-05-14T20:45:30.091Z
Output:
'2021-05-14T20:45:22.091Z'

# Example (3)

setSeconds({ value: 1 })
Input:
1715472000000
Output:
'2024-05-12T00:00:01.000Z'

setTimezone

Type: FIELD_TRANSFORM

Returns the input date with the timezone set to the args value

Arguments

  • timezone: (required) Any - Value to set timezone to in minutes or timezone name. Offset must be between -1440 and 1440

Accepts

  • Date
  • String
  • Number

Examples

# Example (1)

setTimezone({ timezone: 420 })
Input:
'2021-05-14T20:45:30.000Z'
Output:
'2021-05-14T20:45:30.000+07:00'

# Example (2)

setTimezone({ timezone: 'America/Phoenix' })
Input:
'2021-05-14T20:45:30.000Z'
Output:
'2021-05-14T20:45:30.000-07:00'

# Example (3)

setTimezone({ timezone: 120 })
Input:
'2020-02-14T20:45:30.091Z'
Output:
'2020-02-14T20:45:30.091+02:00'

# Example (4)

setTimezone({ timezone: 'Europe/Paris' })
Input:
'2020-02-14T20:45:30.091Z'
Output:
'2020-02-14T20:45:30.091+02:00'

setYear

Type: FIELD_TRANSFORM

Returns the input date with the year set to the args value

Arguments

  • value: (required) Number - Value to set year to, must be an integer

Accepts

  • String
  • Date
  • Number

Examples

# Example (1)

setYear({ value: 2024 })
Input:
'2021-05-14T20:45:30.000Z'
Output:
'2024-05-14T20:45:30.000Z'

# Example (2)

setYear({ value: 1984 })
Input:
2021-05-14T20:45:30.091Z
Output:
'1984-05-14T20:45:30.091Z'

# Example (3)

setYear({ value: 2023 })
Input:
[ 1621026000000, 420 ]
Output:
'2023-05-14T14:00:00.000Z'

# Example (4)

setYear({ value: 2001 })
Input:
1715472000000
Output:
'2001-05-12T00:00:00.000Z'

subtractFromDate

Type: FIELD_TRANSFORM

Returns the input date minus the date expression or a specific number of years, months, weeks, days, hours, minutes, seconds, or milliseconds

Arguments

  • expr: String - The date math expression used to subtract from the input date. For example, 1h or 1h+2m

  • years: Integer - The number of years to subtract from the date. This cannot be specified with expr

  • months: Integer - The number of months to subtract from the date. This cannot be specified with expr

  • weeks: Integer - The number of weeks to subtract from the date. This cannot be specified with expr

  • days: Integer - The number of days to subtract from the date. This cannot be specified with expr

  • hours: Integer - The number of hours to subtract from the date. This cannot be specified with expr

  • minutes: Integer - The number of minutes to subtract from the date. This cannot be specified with expr

  • seconds: Integer - The number of seconds to subtract from the date. This cannot be specified with expr

  • milliseconds: Integer - The number of milliseconds to subtract from the date. This cannot be specified with expr

Accepts

  • Date

Examples

# Example (1)

subtractFromDate({ expr: '10h+2m' })
Input:
'2019-10-22T22:00:00.000Z'
Output:
'2019-10-22T12:02:00.000Z'

# Example (2)

subtractFromDate({ months: 1, minutes: 2 })
Input:
'2019-10-22T22:00:00.000Z'
Output:
'2019-09-22T21:58:00.000Z'

# Example (3)

subtractFromDate()
Input:
'2019-10-22T22:00:00.000Z'

Throws: Expected an expr or years, months, weeks, days, hours, minutes, seconds or milliseconds

# Example (4)

subtractFromDate({ expr: '1hr', months: 10 })
Input:
'2019-10-22T22:00:00.000Z'

Throws: Invalid use of months with expr parameter

timezoneToOffset

Type: FIELD_TRANSFORM

Given a timezone, it will return the offset from UTC in minutes. This uses current server time as the reference for a date, so results may vary depending on daylight saving time adjustments

Accepts

  • String

Examples

# Example (1)

timezoneToOffset()
Input:
'America/Phoenix'
Output:
-420

toDailyDate

Type: FIELD_TRANSFORM

Converts a value to a daily ISO 8601 date segment

Accepts

  • String
  • Number
  • Date

Examples

# Example (1)

toDailyDate()
Input:
'2019-10-22T01:00:00.000Z'
Output:
'2019-10-22T00:00:00.000Z'

# Example (2)

toDailyDate()
Input:
[ 1571706000000, 60 ]
Output:
'2019-10-22T00:00:00.000Z'

toDate

Type: FIELD_TRANSFORM

Converts a value to a date value, specify a format to apply it to the input value

Arguments

  • format: String - When the value is a string, this indicates the date string format. See https://date-fns.org/v2.16.1/docs/parse for more info. Default: iso_8601 for strings and epoch_millis for number

Accepts

  • String
  • Number
  • Date

Examples

# Example (1)

toDate({ format: 'yyyy-MM-dd' })
Input:
'2019-10-22'
Output:
'2019-10-22T00:00:00.000Z'

# Example (2)

toDate()
Input:
102390933
Output:
'1970-01-02T04:26:30.933Z'

# Example (3)

toDate({ format: 'seconds' })
Input:
102390933
Output:
'1973-03-31T01:55:33.000Z'

# Example (4)

toDate({ format: 'milliseconds' })
Input:
102390933000
Output:
'1973-03-31T01:55:33.000Z'

# Example (5)

toDate()
Input:
'2001-01-01T01:00:00.000Z'
Output:
'2001-01-01T01:00:00.000Z'

toHourlyDate

Type: FIELD_TRANSFORM

Converts a value to a hourly ISO 8601 date segment

Accepts

  • String
  • Number
  • Date

Examples

# Example (1)

toHourlyDate()
Input:
'2019-10-22T01:05:20.000Z'
Output:
'2019-10-22T01:00:00.000Z'

toMonthlyDate

Type: FIELD_TRANSFORM

Converts a value to a monthly ISO 8601 date segment

Accepts

  • String
  • Number
  • Date

Examples

# Example (1)

toMonthlyDate()
Input:
'2019-10-22T01:00:00.000Z'
Output:
'2019-10-01T00:00:00.000Z'

# Example (2)

toMonthlyDate()
Input:
[ 1571706000000, 120 ]
Output:
'2019-10-01T00:00:00.000Z'

toYearlyDate

Type: FIELD_TRANSFORM

Converts a value to a yearly ISO 8601 date segment

Accepts

  • String
  • Number
  • Date

Examples

# Example (1)

toYearlyDate()
Input:
'2019-10-22T01:00:00.000Z'
Output:
'2019-01-01T00:00:00.000Z'

isAfter

Type: FIELD_VALIDATION

Returns the input if it is after the arg date, otherwise returns null

Arguments

  • date: (required) Date - Date to compare input to

Accepts

  • Date
  • String
  • Number

Examples

# Example (1)

isAfter({ date: '2021-05-09T10:00:00.000Z' })
Input:
'2021-05-10T10:00:00.000Z'
Output:
'2021-05-10T10:00:00.000Z'

# Example (2)

isAfter({ date: 1620554400000 })
Input:
'2021-05-10T10:00:00.000Z'
Output:
'2021-05-10T10:00:00.000Z'

# Example (3)

isAfter({ date: '2021-05-09T10:00:00.000Z' })
Input:
1620640800000
Output:
1620640800000

# Example (4)

isAfter({ date: '2021-05-10T10:00:00.000Z' })
Input:
'2021-05-09T10:00:00.000Z'
Output:
null

# Example (5)

isAfter({ date: [ 1620640800000, -420 ] })
Input:
'2021-05-10T10:00:00.000Z'
Output:
null

isBefore

Type: FIELD_VALIDATION

Returns the input if it is before the arg date, otherwise returns null

Arguments

  • date: (required) Date - Date to compare input to

Accepts

  • Date
  • String
  • Number

Examples

# Example (1)

isBefore({ date: '2021-05-10T10:00:00.000Z' })
Input:
'2021-05-09T10:00:00.000Z'
Output:
'2021-05-09T10:00:00.000Z'

# Example (2)

isBefore({ date: '2021-05-10T10:00:00.000Z' })
Input:
1620554400000
Output:
1620554400000

# Example (3)

isBefore({ date: 1620640800000 })
Input:
'2021-05-09T10:00:00.000Z'
Output:
'2021-05-09T10:00:00.000Z'

# Example (4)

isBefore({ date: '2021-05-10T10:00:00.000Z' })
Input:
'2021-05-11T10:00:00.000Z'
Output:
null

isBetween

Type: FIELD_VALIDATION

Returns the input if it is between the args start and end dates, otherwise returns null

Arguments

  • start: (required) Date - Start date of time range

  • end: (required) Date - End date of time range

Accepts

  • Date
  • String
  • Number

Examples

# Example (1)

isBetween({ start: '2021-05-09T10:00:00.001Z', end: '2021-05-11T10:00:00.001Z' })
Input:
'2021-05-10T10:00:00.001Z'
Output:
'2021-05-10T10:00:00.001Z'

# Example (2)

isBetween({ start: 1620554400000, end: 1620640800000 })
Input:
1620554401000
Output:
1620554401000

# Example (3)

isBetween({ start: '2021-05-09T10:00:00.001Z', end: '2021-05-11T10:00:00.001Z' })
Input:
'2021-05-07T10:00:00.000Z'
Output:
null

# Example (4)

isBetween({ start: '2021-05-09T10:00:00.001Z', end: '2021-05-11T10:00:00.001Z' })
Input:
'2021-05-15T10:00:00.000Z'
Output:
null

isDate

Type: FIELD_VALIDATION

Returns the input if it is a valid date, if format is provided the format will be applied to the validation

Arguments

  • format: String - When the value is a string, this indicates the date string format. See https://date-fns.org/v2.16.1/docs/parse for more info. Default: iso_8601 for strings and epoch_millis for number

Accepts

  • Date
  • String
  • Number

Examples

# Example (1)

isDate({ format: 'yyyy-MM-dd' })
Input:
'2019-10-22'
Output:
'2019-10-22'

# Example (2)

isDate({ format: 'yyyy-MM-dd' })
Input:
'10-22-2019'
Output:
null

# Example (3)

isDate({ format: 'epoch' })
Input:
102390933
Output:
102390933

# Example (4)

isDate()
Input:
'2001-01-01T01:00:00.000Z'
Output:
'2001-01-01T01:00:00.000Z'

isEpoch

Type: FIELD_VALIDATION Aliases: isUnixTime

Returns the input if it is a valid epoch timestamp. Accuracy is not guaranteed since any number could be a valid epoch timestamp

Arguments

  • allowBefore1970: Boolean - Set to false to disable allowing negative values

Accepts

  • Number

Examples

# Example (1)

isEpoch()
Input:
'2019-10-22'
Output:
null

# Example (2)

isEpoch()
Input:
102390933
Output:
102390933

# Example (3)

isEpoch()
Input:
'2001-01-01T01:00:00.000Z'
Output:
null

# Example (4)

isEpoch({ allowBefore1970: false })
Input:
-102390933
Output:
null

# Example (5)

isEpoch()
Input:
-102390933
Output:
-102390933

isEpochMillis

Type: FIELD_VALIDATION

Returns the input if it is a valid epoch timestamp (in milliseconds). Accuracy is not guaranteed since any number could be a valid epoch timestamp

Arguments

  • allowBefore1970: Boolean - Set to false to disable allowing negative values

Accepts

  • Number

Examples

# Example (1)

isEpochMillis()
Input:
'2019-10-22'
Output:
null

# Example (2)

isEpochMillis()
Input:
102390933
Output:
102390933

# Example (3)

isEpochMillis()
Input:
'2001-01-01T01:00:00.000Z'
Output:
null

# Example (4)

isEpochMillis({ allowBefore1970: false })
Input:
-102390933
Output:
null

# Example (5)

isEpochMillis()
Input:
-102390933
Output:
-102390933

isFriday

Type: FIELD_VALIDATION

Returns the given date if it is on a Friday, otherwise returns null

Accepts

  • String
  • Date
  • Number

Examples

# Example (1)

isFriday()
Input:
'2021-05-14T10:00:00.000Z'
Output:
'2021-05-14T10:00:00.000Z'

# Example (2)

isFriday()
Input:
[ 1620986400000, -620 ]
Output:
'2021-05-14T10:00:00.000-10:20'

# Example (3)

isFriday()
Input:
'2021-05-09T10:00:00.000Z'
Output:
null

isFuture

Type: FIELD_VALIDATION

Returns the the input if it is in the future, otherwise returns null

Accepts

  • String
  • Date
  • Number

Examples

# Example (1)

isFuture()
Input:
'2021-05-10T10:00:00.000Z'
Output:
null

# Example (2)

isFuture()
Input:
'2121-05-09T10:00:00.000Z'
Output:
'2121-05-09T10:00:00.000Z'

isISO8601

Type: FIELD_VALIDATION

Returns the input if it is a valid ISO-8601 date, otherwise returns null

Accepts

  • Date
  • String
  • Number

Examples

# Example (1)

isISO8601()
Input:
102390933
Output:
null

# Example (2)

isISO8601()
Input:
'2001-01-01T01:00:00.000Z'
Output:
'2001-01-01T01:00:00.000Z'

# Example (3)

isISO8601()
Input:
102390933
Output:
null

isLeapYear

Type: FIELD_VALIDATION

Returns the the input if it is in a leap year, otherwise returns null

Accepts

  • String
  • Date
  • Number

Examples

# Example (1)

isLeapYear()
Input:
'2020-05-10T10:00:00.000Z'
Output:
'2020-05-10T10:00:00.000Z'

# Example (2)

isLeapYear()
Input:
[ 1589104800000, 60 ]
Output:
'2020-05-10T10:00:00.000+01:00'

# Example (3)

isLeapYear()
Input:
'2021-05-10T10:00:00.000Z'
Output:
null

isMonday

Type: FIELD_VALIDATION

Returns the the input if it is on a Monday

Accepts

  • String
  • Date
  • Number

Examples

# Example (1)

isMonday()
Input:
'2021-05-10T10:00:00.000Z'
Output:
'2021-05-10T10:00:00.000Z'

# Example (2)

isMonday()
Input:
'2021-05-09T10:00:00.000Z'
Output:
null

isPast

Type: FIELD_VALIDATION

Returns the input if it is in the past, otherwise returns null

Accepts

  • String
  • Date
  • Number

Examples

# Example (1)

isPast()
Input:
'2021-05-10T10:00:00.000Z'
Output:
'2021-05-10T10:00:00.000Z'

# Example (2)

isPast()
Input:
'2121-05-09T10:00:00.000Z'
Output:
null

isSaturday

Type: FIELD_VALIDATION

Returns the input if it is on a Saturday, otherwise returns null

Accepts

  • String
  • Date
  • Number

Examples

# Example (1)

isSaturday()
Input:
'2021-05-08T10:00:00.000Z'
Output:
'2021-05-08T10:00:00.000Z'

# Example (2)

isSaturday()
Input:
'2021-05-09T10:00:00.000Z'
Output:
null

isSunday

Type: FIELD_VALIDATION

Returns the input if it is on a Sunday, otherwise returns null

Accepts

  • String
  • Date
  • Number

Examples

# Example (1)

isSunday()
Input:
'2021-05-09T10:00:00.000Z'
Output:
'2021-05-09T10:00:00.000Z'

# Example (2)

isSunday()
Input:
1620554400000
Output:
1620554400000

isThursday

Type: FIELD_VALIDATION

Returns the input if it is on a Thursday, otherwise returns null

Accepts

  • String
  • Date
  • Number

Examples

# Example (1)

isThursday()
Input:
'2021-05-13T10:00:00.000Z'
Output:
'2021-05-13T10:00:00.000Z'

# Example (2)

isThursday()
Input:
'2021-05-09T10:00:00.000Z'
Output:
null

isToday

Type: FIELD_VALIDATION

Returns the input if it is on the same day (utc-time), otherwise returns null

Accepts

  • String
  • Date
  • Number

Examples

This input is created at execution time

# Example (1)

isToday()
Input:
'2021-10-28T22:06:00.484Z'
Output:
'2021-10-28T22:06:00.484Z'

# Example (2)

isToday()
Input:
'2020-05-09T10:00:00.000Z'
Output:
null

isTomorrow

Type: FIELD_VALIDATION

Returns the input if it is on the next day (utc-time), otherwise returns null

Accepts

  • String
  • Date
  • Number

Examples

Represents current time

# Example (1)

isTomorrow()
Input:
'2021-10-28T22:06:00.485Z'
Output:
null

Represents day after current time

# Example (2)

isTomorrow()
Input:
'2021-10-29T22:06:00.485Z'
Output:
'2021-10-29T22:06:00.485Z'

isTuesday

Type: FIELD_VALIDATION

Returns the input if it is on a Tuesday, otherwise returns null

Accepts

  • String
  • Date
  • Number

Examples

# Example (1)

isTuesday()
Input:
'2021-05-11T10:00:00.000Z'
Output:
'2021-05-11T10:00:00.000Z'

# Example (2)

isTuesday()
Input:
'2021-05-09T10:00:00.000Z'
Output:
null

isWednesday

Type: FIELD_VALIDATION

Returns the input if it is on a Wednesday, otherwise returns null

Accepts

  • String
  • Date
  • Number

Examples

# Example (1)

isWednesday()
Input:
'2021-05-12T10:00:00.000Z'
Output:
'2021-05-12T10:00:00.000Z'

# Example (2)

isWednesday()
Input:
'2021-05-09T10:00:00.000Z'
Output:
null

isWeekday

Type: FIELD_VALIDATION

Returns the input if it is on a Weekday (Monday-Friday), otherwise returns null

Accepts

  • String
  • Date
  • Number

Examples

# Example (1)

isWeekday()
Input:
'2021-05-12T10:00:00.000Z'
Output:
'2021-05-12T10:00:00.000Z'

# Example (2)

isWeekday()
Input:
'2021-05-13T10:00:00.000Z'
Output:
'2021-05-13T10:00:00.000Z'

# Example (3)

isWeekday()
Input:
'2021-05-09T10:00:00.000Z'
Output:
null

# Example (4)

isWeekday()
Input:
'2021-05-08T10:00:00.000Z'
Output:
null

isWeekend

Type: FIELD_VALIDATION

Returns the input if it is on a Weekend (Saturday-Sunday), otherwise returns null

Accepts

  • String
  • Date
  • Number

Examples

# Example (1)

isWeekend()
Input:
'2021-05-12T10:00:00.000Z'
Output:
null

# Example (2)

isWeekend()
Input:
'2021-05-13T10:00:00.000Z'
Output:
null

# Example (3)

isWeekend()
Input:
'2021-05-09T10:00:00.000Z'
Output:
'2021-05-09T10:00:00.000Z'

# Example (4)

isWeekend()
Input:
'2021-05-08T10:00:00.000Z'
Output:
'2021-05-08T10:00:00.000Z'

isYesterday

Type: FIELD_VALIDATION

Returns the input if it is on the day before (utc-time), otherwise returns null

Accepts

  • String
  • Date
  • Number

Examples

Represents current time

# Example (1)

isYesterday()
Input:
'2021-10-28T22:06:00.488Z'
Output:
null

Represents day before current time

# Example (2)

isYesterday()
Input:
'2021-10-27T22:06:00.488Z'
Output:
'2021-10-27T22:06:00.488Z'

CATEGORY: Numeric

abs

Type: FIELD_TRANSFORM

Returns the absolute value of a number

Accepts

  • Number

Examples

# Example (1)

abs()
Input:
-1
Output:
1

acos

Type: FIELD_TRANSFORM

Returns a numeric value between 0 and π radians for x between -1 and 1

Accepts

  • Number

Examples

# Example (1)

acos()
Input:
-1
Output:
3.141592653589793

acosh

Type: FIELD_TRANSFORM

Returns the hyperbolic arc-cosine of a given number. If given the number is less than 1, returns null

Accepts

  • Number

Examples

# Example (1)

acosh()
Input:
1
Output:
0

Since this function doesn't work with numbers <=0, null will be returned

# Example (2)

acosh()
Input:
0
Output:
null

add

Type: FIELD_TRANSFORM

Returns the sum of the input and the args value

Arguments

  • value: (required) Number - Value to add to the input

Accepts

  • Number

Examples

# Example (1)

add({ value: 1 })
Input:
10
Output:
11

# Example (2)

add({ value: 5 })
Input:
10
Output:
15

# Example (3)

add({ value: -5 })
Input:
10
Output:
5

# Example (4)

add({ value: 12 })
Input:
12
Output:
24

addValues

Type: FIELD_TRANSFORM

Adds the values with a given field, this requires an array to function correctly

Accepts

  • Number

Examples

# Example (1)

addValues()
Input:
[ 100, 10 ]
Output:
110

# Example (2)

addValues()
Input:
[ 10 ]
Output:
10

# Example (3)

addValues()
Input:
[ 10, 100000, 2 ]
Output:
100012

# Example (4)

addValues()
Input:
[ [ 10, null ], 100000, [ 2 ], null ]
Output:
100012

# Example (5)

addValues()
Input:
2
Output:
2

asin

Type: FIELD_TRANSFORM

Returns the arcsine (in radians) of the given number if it's between -1 and 1

Accepts

  • Number

Examples

# Example (1)

asin()
Input:
1
Output:
1.5707963267948966

asinh

Type: FIELD_TRANSFORM

Returns the hyperbolic arcsine of the given number

Accepts

  • Number

Examples

# Example (1)

asinh()
Input:
1
Output:
0.881373587019543

atan

Type: FIELD_TRANSFORM

Returns the arctangent (in radians) of the given number

Accepts

  • Number

Examples

# Example (1)

atan()
Input:
1
Output:
0.7853981633974483

atan2

Type: FIELD_TRANSFORM

Returns the angle in the plane (in radians) between the positive x-axis and the ray from (0,0) to the point (x,y), for atan2(y,x)

Accepts

  • Number

Examples

# Example (1)

atan2()
Input:
[ 15, 90 ]
Output:
1.4056476493802699

# Example (2)

atan2()
Input:
[ 90, 15 ]
Output:
0.16514867741462683

# Example (3)

atan2()
Input:
[ -90, null ]

Throws: Expected (x, y) coordinates, got [-90,null] (Array)

atanh

Type: FIELD_TRANSFORM

Returns the arctangent (in radians) of the given number

Accepts

  • Number

Examples

# Example (1)

atanh()
Input:
0.5
Output:
0.5493061443340548

Typically this would return -Infinity but that cannot be stored or serialized so null is returned

# Example (2)

atanh()
Input:
-1
Output:
null

cbrt

Type: FIELD_TRANSFORM

Returns the cube root of a number

Accepts

  • Number

Examples

# Example (1)

cbrt()
Input:
64
Output:
4

# Example (2)

cbrt()
Input:
1
Output:
1

ceil

Type: FIELD_TRANSFORM

Rounds a number up to the next largest integer

Accepts

  • Number

Examples

# Example (1)

ceil()
Input:
0.95
Output:
1

# Example (2)

ceil()
Input:
0.1
Output:
1

# Example (3)

ceil()
Input:
-7.004
Output:
-7

clz32

Type: FIELD_TRANSFORM

Returns the number of leading zero bits in the 32-bit binary representation of a number

Accepts

  • Number

Examples

# Example (1)

clz32()
Input:
1
Output:
31

# Example (2)

clz32()
Input:
1000
Output:
22

# Example (3)

clz32()
Input:
4
Output:
29

cos

Type: FIELD_TRANSFORM

Returns the cosine of the specified angle, which must be specified in radians

Accepts

  • Number

Examples

# Example (1)

cos()
Input:
0
Output:
1

# Example (2)

cos()
Input:
3.141592653589793
Output:
-1

# Example (3)

cos()
Input:
6.283185307179586
Output:
1

cosh

Type: FIELD_TRANSFORM

Returns the hyperbolic cosine of a number that can be expressed using the constant e

Accepts

  • Number

Examples

# Example (1)

cosh()
Input:
0
Output:
1

# Example (2)

cosh()
Input:
3.141592653589793
Output:
11.591953275521519

divide

Type: FIELD_TRANSFORM

Returns the quotient from the input divided by the args value

Arguments

  • value: (required) Number - Value to divide into the input

Accepts

  • Number

Examples

# Example (1)

divide({ value: 5 })
Input:
10
Output:
2

# Example (2)

divide({ value: 1 })
Input:
10
Output:
10

# Example (3)

divide({ value: 2 })
Input:
10
Output:
5

divideValues

Type: FIELD_TRANSFORM

Divides the values with a given field, this requires an array to function correctly

Accepts

  • Number

Examples

# Example (1)

divideValues()
Input:
[ 100, 10 ]
Output:
10

# Example (2)

divideValues()
Input:
[ 10 ]
Output:
10

# Example (3)

divideValues()
Input:
[ 10, 100000, 2 ]
Output:
0.00005

# Example (4)

divideValues()
Input:
[ [ 10, null ], 100000, [ 2 ], null ]
Output:
0.00005

# Example (5)

divideValues()
Input:
2
Output:
2

# Example (6)

divideValues()
Input:
[ 0, 0 ]
Output:
NaN

# Example (7)

divideValues()
Input:
[ 100, 0 ]
Output:
Infinity

exp

Type: FIELD_TRANSFORM

Returns a number representing e^x, where e is Euler's number and x is the argument

Accepts

  • Number

Examples

# Example (1)

exp()
Input:
0
Output:
1

# Example (2)

exp()
Input:
1
Output:
2.718281828459045

expm1

Type: FIELD_TRANSFORM

Returns a number representing e^x - 1, where e is Euler's number and x is the argument

Accepts

  • Number

Examples

# Example (1)

expm1()
Input:
0
Output:
0

# Example (2)

expm1()
Input:
1
Output:
1.718281828459045

floor

Type: FIELD_TRANSFORM

Rounds a number down to the previous largest integer

Accepts

  • Number

Examples

# Example (1)

floor()
Input:
0.95
Output:
0

# Example (2)

floor()
Input:
0.1
Output:
0

# Example (3)

floor()
Input:
-7.004
Output:
-8

fround

Type: FIELD_TRANSFORM

Returns the nearest 32-bit single precision float representation of the given number

Accepts

  • Number

Examples

# Example (1)

fround()
Input:
5.5
Output:
5.5

# Example (2)

fround()
Input:
-5.05
Output:
-5.050000190734863

hypot

Type: FIELD_TRANSFORM

Returns the square root of the sum of squares of the given arguments. If at least one of the arguments cannot be converted to a number, null is returned

Accepts

  • Number

Examples

# Example (1)

hypot()
Input:
[ 3, 4 ]
Output:
5

# Example (2)

hypot()
Input:
[ 5, 12 ]
Output:
13

# Example (3)

hypot()
Input:
[ 3, 4, null, 5 ]
Output:
7.0710678118654755

# Example (4)

hypot()
Input:
null
Output:
null

log

Type: FIELD_TRANSFORM

Returns the natural logarithm (base e) of the given number. If the number is negative, null is returned

Accepts

  • Number

Examples

# Example (1)

log()
Input:
1
Output:
0

# Example (2)

log()
Input:
10
Output:
2.302585092994046

# Example (3)

log()
Input:
-1
Output:
null

log1p

Type: FIELD_TRANSFORM

Returns the natural logarithm (base e) of 1 plus the given number. If the number is less than -1, null is returned

Accepts

  • Number

Examples

# Example (1)

log1p()
Input:
1
Output:
0.6931471805599453

# Example (2)

log1p()
Input:
0
Output:
0

Typically this would return -Infinity but that cannot be stored or serialized so null is returned

# Example (3)

log1p()
Input:
-1
Output:
null

Typically this would return NaN but that cannot be stored or serialized so null is returned

# Example (4)

log1p()
Input:
-2
Output:
null

log2

Type: FIELD_TRANSFORM

Returns the base 2 logarithm of the given number. If the number is negative, null is returned

Accepts

  • Number

Examples

# Example (1)

log2()
Input:
2
Output:
1

Typically this would return -Infinity but that cannot be stored or serialized so null is returned

# Example (2)

log2()
Input:
0
Output:
null

# Example (3)

log2()
Input:
-2
Output:
null

log10

Type: FIELD_TRANSFORM

Returns the base 10 logarithm of the given number. If the number is negative, null is returned

Accepts

  • Number

Examples

# Example (1)

log10()
Input:
10
Output:
1

Typically this would return -Infinity but that cannot be stored or serialized so null is returned

# Example (2)

log10()
Input:
0
Output:
null

# Example (3)

log10()
Input:
-2
Output:
null

maxValues

Type: FIELD_TRANSFORM

Returns the maximum value in an array, this requires an array to function correctly

Accepts

  • Number

Examples

# Example (1)

maxValues()
Input:
[ 100, 10 ]
Output:
100

# Example (2)

maxValues()
Input:
[ 10 ]
Output:
10

# Example (3)

maxValues()
Input:
[ 10, 100000, 2 ]
Output:
100000

# Example (4)

maxValues()
Input:
[ [ 10, null ], 100000, [ 2 ], null ]
Output:
100000

# Example (5)

maxValues()
Input:
2
Output:
2

minValues

Type: FIELD_TRANSFORM

Returns the minimum value in an array, this requires an array to function correctly

Accepts

  • Number

Examples

# Example (1)

minValues()
Input:
[ 100, 10 ]
Output:
10

# Example (2)

minValues()
Input:
[ 10 ]
Output:
10

# Example (3)

minValues()
Input:
[ 10, 100000, 2 ]
Output:
2

# Example (4)

minValues()
Input:
[ [ 10, null ], 100000, [ 2 ], null ]
Output:
2

# Example (5)

minValues()
Input:
2
Output:
2

modulus

Type: FIELD_TRANSFORM Aliases: mod

Returns the modulus from the input divided by the args value

Arguments

  • value: (required) Number - Value to divide into the input

Accepts

  • Number

Examples

# Example (1)

modulus({ value: 2 })
Input:
10
Output:
0

# Example (2)

modulus({ value: 2 })
Input:
9
Output:
1

# Example (3)

modulus({ value: -5 })
Input:
10
Output:
0

# Example (4)

modulus({ value: 10 })
Input:
101
Output:
1

multiply

Type: FIELD_TRANSFORM

Returns the product of the input multiplied by the args value

Arguments

  • value: (required) Number - Value to multiply the input by

Accepts

  • Number

Examples

# Example (1)

multiply({ value: 5 })
Input:
10
Output:
50

# Example (2)

multiply({ value: -2 })
Input:
10
Output:
-20

# Example (3)

multiply({ value: 2 })
Input:
10
Output:
20

multiplyValues

Type: FIELD_TRANSFORM

Multiplies the values with a given field, this requires an array to function correctly

Accepts

  • Number

Examples

# Example (1)

multiplyValues()
Input:
[ 100, 10 ]
Output:
1000

# Example (2)

multiplyValues()
Input:
[ 10 ]
Output:
10

# Example (3)

multiplyValues()
Input:
[ 10, 100000, 2 ]
Output:
2000000

# Example (4)

multiplyValues()
Input:
[ [ 10, null ], 100000, [ 2 ], null ]
Output:
2000000

# Example (5)

multiplyValues()
Input:
2
Output:
2

pow

Type: FIELD_TRANSFORM Aliases: power

Returns a number representing the input value taken to the power of the value

Arguments

  • value: (required) Number - The exponent used to raise the base

Accepts

  • Number

Examples

# Example (1)

pow({ value: 3 })
Input:
7
Output:
343

# Example (2)

pow({ value: 0.5 })
Input:
4
Output:
2

random

Type: FIELD_TRANSFORM

Returns a random number between the args min and max values

Arguments

  • min: (required) Number - The minimum value in the range

  • max: (required) Number - The maximum value in the range

Examples

# Example (1)

random({ min: 1, max: 1 })
Input:
1
Output:
1

round

Type: FIELD_TRANSFORM

Returns the value of a number rounded to the nearest integer

Accepts

  • Number

Examples

# Example (1)

round()
Input:
0.95
Output:
1

# Example (2)

round()
Input:
0.1
Output:
0

# Example (3)

round()
Input:
-7.004
Output:
-7

setPrecision

Type: FIELD_TRANSFORM

Returns a truncated number to the nth decimal places. The values will skip rounding if truncate: true is specified

Arguments

  • digits: (required) Number - The number of decimal places to keep. This value must be between 0-100

  • truncate: Boolean - If set to true rounding will be disabled

Accepts

  • Number
  • GeoPoint
  • Geo

Examples

# Example (1)

setPrecision({ digits: 1, truncate: false })
Input:
'10.123444'
Output:
10.1

# Example (2)

setPrecision({ digits: 1, truncate: true })
Input:
10.253444
Output:
10.2

# Example (3)

setPrecision({ digits: 1, truncate: false })
Input:
10.253444
Output:
10.3

# Example (4)

setPrecision({ digits: 2 })
Input:
3.141592653589793
Output:
3.14

# Example (5)

setPrecision({ digits: 0 })
Input:
3.141592653589793
Output:
3

# Example (6)

setPrecision({ digits: -1 })
Input:
23.4

Throws: Expected digits to be between 0-100

# Example (7)

setPrecision({ digits: 1000 })
Input:
23.4

Throws: Expected digits to be between 0-100

# Example (8)

setPrecision({ digits: 2, truncate: true })
Input:
{ lat: 32.12399971230023, lon: -20.95522300035 }
Output:
{ lat: 32.12, lon: -20.95 }

# Example (9)

setPrecision({ digits: 2, truncate: true })
Input:
{ lat: 32.12399971230023, lon: -20.95522300035 }
Output:
{ lat: 32.12, lon: -20.95 }

# Example (10)

setPrecision({ digits: 2 })
Input:
NaN
Output:
NaN

# Example (11)

setPrecision({ digits: 2 })
Input:
Infinity
Output:
Infinity

sign

Type: FIELD_TRANSFORM

Returns a number representing the sign of the input value:

  • If the argument is positive, returns 1
  • If the argument is negative, returns -1
  • If the argument is positive zero, returns 0
  • If the argument is negative zero, returns -0
  • Otherwise, null is returned

Accepts

  • Number

Examples

# Example (1)

sign()
Input:
3
Output:
1

# Example (2)

sign()
Input:
-3
Output:
-1

# Example (3)

sign()
Input:
0
Output:
0

sin

Type: FIELD_TRANSFORM

Returns the sine of the input value

Accepts

  • Number

Examples

# Example (1)

sin()
Input:
0
Output:
0

# Example (2)

sin()
Input:
1
Output:
0.8414709848078965

# Example (3)

sin()
Input:
1.5707963267948966
Output:
1

sinh

Type: FIELD_TRANSFORM

Returns the hyperbolic sine of the input, that can be expressed using the constant e

Accepts

  • Number

Examples

# Example (1)

sinh()
Input:
0
Output:
0

# Example (2)

sinh()
Input:
1
Output:
1.1752011936438014

# Example (3)

sinh()
Input:
-1
Output:
-1.1752011936438014

sqrt

Type: FIELD_TRANSFORM

Returns the square root of the input

Accepts

  • Number

Examples

# Example (1)

sqrt()
Input:
9
Output:
3

# Example (2)

sqrt()
Input:
2
Output:
1.4142135623730951

# Example (3)

sqrt()
Input:
-1
Output:
null

subtract

Type: FIELD_TRANSFORM

Returns the result of subtracting the args value from the input value

Arguments

  • value: Number - Value to subtract from the input

Accepts

  • Number

Examples

# Example (1)

subtract({ value: 1 })
Input:
10
Output:
9

# Example (2)

subtract({ value: 5 })
Input:
10
Output:
5

# Example (3)

subtract({ value: -5 })
Input:
10
Output:
15

# Example (4)

subtract({ value: 2 })
Input:
10
Output:
8

subtractValues

Type: FIELD_TRANSFORM

Subtracts the values with a given field, this requires an array to function correctly

Accepts

  • Number

Examples

# Example (1)

subtractValues()
Input:
[ 100, 10 ]
Output:
90

# Example (2)

subtractValues()
Input:
[ 10 ]
Output:
10

# Example (3)

subtractValues()
Input:
[ 10, 100000, 2 ]
Output:
-99992

# Example (4)

subtractValues()
Input:
[ [ 10, null ], 100000, [ 2 ], null ]
Output:
-99992

# Example (5)

subtractValues()
Input:
2
Output:
2

tan

Type: FIELD_TRANSFORM

Returns the tangent of a number

Accepts

  • Number

Examples

# Example (1)

tan()
Input:
1
Output:
1.5574077246549023

tanh

Type: FIELD_TRANSFORM

Returns the hyperbolic tangent of a number

Accepts

  • Number

Examples

# Example (1)

tanh()
Input:
-1
Output:
-0.7615941559557649

# Example (2)

tanh()
Input:
0
Output:
0

toCelsius

Type: FIELD_TRANSFORM

Returns the equivalent celsius value from the fahrenheit input

Accepts

  • Number

Examples

# Example (1)

toCelsius()
Input:
32
Output:
0

# Example (2)

toCelsius()
Input:
69.8
Output:
21

toFahrenheit

Type: FIELD_TRANSFORM

Returns the equivalent fahrenheit value from the celsius input

Accepts

  • Number

Examples

# Example (1)

toFahrenheit()
Input:
0
Output:
32

# Example (2)

toFahrenheit()
Input:
22
Output:
71.6

toNumber

Type: FIELD_TRANSFORM

Converts an entity to a number, can handle IPs and Dates

Examples

# Example (1)

toNumber()
Input:
'9007199254740991'
Output:
9007199254740991

# Example (2)

toNumber()
Input:
'22'
Output:
22

# Example (3)

toNumber()
Input:
'22'
Output:
22

# Example (4)

toNumber()
Input:
'10.16.32.210'
Output:
168829138

# Example (5)

toNumber()
Input:
'2001:2::'
Output:
'42540488320432167789079031612388147199'

# Example (6)

toNumber()
Input:
'2001-01-01T01:00:00.000Z'
Output:
978310800000

inNumberRange

Type: FIELD_VALIDATION

Returns the input if it is within the given min and max values, arg option for inclusive or exclusive

Arguments

  • min: Number - The minimum value allowed in the range, defaults to Negative Infinity

  • max: Number - The maximum value allowed in the range, defaults to Positive Infinity

  • inclusive: Boolean - Whether not the min and max values should be included in the range

Accepts

  • Number

Examples

# Example (1)

inNumberRange({ min: 100, max: 110 })
Input:
10
Output:
null

# Example (2)

inNumberRange({ min: 100 })
Input:
100
Output:
null

# Example (3)

inNumberRange({ min: 100, inclusive: true })
Input:
100
Output:
100

# Example (4)

inNumberRange({ min: 0, max: 100 })
Input:
10
Output:
10

# Example (5)

inNumberRange({ min: 100, inclusive: true })
Input:
Infinity
Output:
Infinity

# Example (6)

inNumberRange({ min: 100, inclusive: true })
Input:
-Infinity
Output:
null

isEven

Type: FIELD_VALIDATION

Returns the input if it is an even number

Accepts

  • Number

Examples

# Example (1)

isEven()
Input:
100
Output:
100

# Example (2)

isEven()
Input:
99
Output:
null

isGreaterThan

Type: FIELD_VALIDATION

Returns the input if it is greater than the args value

Arguments

  • value: (required) Number

Accepts

  • Number

Examples

# Example (1)

isGreaterThan({ value: 100 })
Input:
10
Output:
null

# Example (2)

isGreaterThan({ value: 50 })
Input:
50
Output:
null

# Example (3)

isGreaterThan({ value: 110 })
Input:
120
Output:
120

# Example (4)

isGreaterThan({ value: 150 })
Input:
151
Output:
151

isGreaterThanOrEqualTo

Type: FIELD_VALIDATION

Returns the input if it is greater than or equal to the args value

Arguments

  • value: (required) Number

Accepts

  • Number

Examples

# Example (1)

isGreaterThanOrEqualTo({ value: 100 })
Input:
10
Output:
null

# Example (2)

isGreaterThanOrEqualTo({ value: 50 })
Input:
50
Output:
50

# Example (3)

isGreaterThanOrEqualTo({ value: 110 })
Input:
120
Output:
120

# Example (4)

isGreaterThanOrEqualTo({ value: 150 })
Input:
151
Output:
151

isLessThan

Type: FIELD_VALIDATION

Returns the input if it is a number less than the args value

Arguments

  • value: (required) Number

Accepts

  • Number

Examples

# Example (1)

isLessThan({ value: 100 })
Input:
110
Output:
null

# Example (2)

isLessThan({ value: 50 })
Input:
50
Output:
null

# Example (3)

isLessThan({ value: 110 })
Input:
100
Output:
100

# Example (4)

isLessThan({ value: 150 })
Input:
149
Output:
149

isLessThanOrEqualTo

Type: FIELD_VALIDATION

Returns the input if it is a number less than or equal to the args value

Arguments

  • value: (required) Number

Accepts

  • Number

Examples

# Example (1)

isLessThanOrEqualTo({ value: 100 })
Input:
110
Output:
null

# Example (2)

isLessThanOrEqualTo({ value: 50 })
Input:
50
Output:
50

# Example (3)

isLessThanOrEqualTo({ value: 110 })
Input:
100
Output:
100

# Example (4)

isLessThanOrEqualTo({ value: 150 })
Input:
149
Output:
149

isOdd

Type: FIELD_VALIDATION

Returns the input if it is an odd number

Accepts

  • Number

Examples

# Example (1)

isOdd()
Input:
100
Output:
null

# Example (2)

isOdd()
Input:
99
Output:
99

CATEGORY: Object

equals

Type: FIELD_VALIDATION

Returns the input if it matches the args value, otherwise returns null

Arguments

  • value: (required) Any - Value to use in the comparison

Examples

# Example (1)

equals({ value: 'thisisastring' })
Input:
'thisisastring'
Output:
'thisisastring'

# Example (2)

equals({ value: 'thisisastring' })
Input:
1234
Output:
null

# Example (3)

equals({ value: [ 'an', 'array', 'of', 'values' ] })
Input:
[ 'an', 'array', 'of', 'values' ]
Output:
[ 'an', 'array', 'of', 'values' ]

# Example (4)

equals({ value: { foo: 'bar', deep: { value: 'kitty' } } })
Input:
{ foo: 'bar', deep: { value: 'kitty' } }
Output:
{ foo: 'bar', deep: { value: 'kitty' } }

# Example (5)

equals({ value: { foo: 'bar', deep: { value: 'kitty' } } })
Input:
{ foo: 'bar', deep: { value: 'other stuff' } }
Output:
null

# Example (6)

equals({ value: true })
Input:
false
Output:
null

isEmpty

Type: FIELD_VALIDATION

Returns the input if it is empty, otherwise returns null

Arguments

  • ignoreWhitespace: Boolean - If input is a string, it will attempt to trim it before validating it

Examples

# Example (1)

isEmpty()
Input:
'85031b6f407e7f25cf826193338f7a4c2dc8c8b5130f5ca2c69a66d9f5107e33'
Output:
null

# Example (2)

isEmpty()
Input:
''
Output:
''

# Example (3)

isEmpty()
Input:
[]
Output:
[]

lookup

Type: FIELD_TRANSFORM

Matches the input to a key in a table and returns the corresponding value

Arguments

  • in: (required) Any - Data set that is used for the key lookup. Can be an object, array, or formatted string (see example). Keys must be strings or numbers

Accepts

  • Number
  • String

Examples

# Example (1)

lookup({ in: { key1: 'value1', key2: 'value2' } })
Input:
'key1'
Output:
'value1'

# Example (2)

lookup({ in: { '123': 4567, '8910': 1112 } })
Input:
8910
Output:
1112

# Example (3)

lookup({ in: { key1: 'value1', key2: 'value2' } })
Input:
'key3'
Output:
undefined

# Example (4)

lookup({
in: '\n' +
' 1:foo\n' +
' 2:bar\n' +
' 3:max\n' +
' '
})
Input:
2
Output:
'bar'

# Example (5)

lookup({ in: [ 'foo', 'bar', 'max' ] })
Input:
2
Output:
'max'

# Example (6)

lookup({ in: [ 'foo', 'bar', 'max' ] })
Input:
2
Output:
'max'

CATEGORY: String

contains

Type: FIELD_VALIDATION

Returns the input string if it contains the args substring value, otherwise returns null. This operations is case-sensitive

Arguments

  • value: (required) String - A string that must partially or completely match

Accepts

  • String

Examples

# Example (1)

contains({ value: 'ample' })
Input:
'example'
Output:
'example'

# Example (2)

contains({ value: 'example' })
Input:
'example'
Output:
'example'

# Example (3)

contains({ value: 'test' })
Input:
'example'
Output:
null

endsWith

Type: FIELD_VALIDATION

Returns the input if it ends with the args value string, otherwise returns null. This is case-sensitive

Arguments

  • value: (required) String - The value compared to the end of the input string

Accepts

  • String

Examples

# Example (1)

endsWith({ value: 'e' })
Input:
'apple'
Output:
'apple'

# Example (2)

endsWith({ value: 'a' })
Input:
'orange'
Output:
null

# Example (3)

endsWith({ value: 'so' })
Input:
'some word'
Output:
null

# Example (4)

endsWith({ value: 'word' })
Input:
'other word'
Output:
'other word'

isAlpha

Type: FIELD_VALIDATION

Returns the input if it is a string composed of only alphabetical characters, otherwise returns null

Arguments

  • locale: String - Specify the locale to check for valid alphabetical characters, defaults to en-US if not provided

Accepts

  • String

Examples

# Example (1)

isAlpha()
Input:
'example123456'
Output:
null

# Example (2)

isAlpha({ locale: 'pl-Pl' })
Input:
'ThisiZĄĆĘŚŁ'
Output:
'ThisiZĄĆĘŚŁ'

# Example (3)

isAlpha()
Input:
'not_alpha.com'
Output:
null

# Example (4)

isAlpha()
Input:
true
Output:
null

isAlphaNumeric

Type: FIELD_VALIDATION

Returns the input if it is a string composed of only alpha-numeric characters, otherwise returns null

Arguments

  • locale: String - Specify locale to check for valid alpha-numeric characters, defaults to en-US if not provided

Accepts

  • String

Examples

# Example (1)

isAlphaNumeric()
Input:
'example123456'
Output:
'example123456'

# Example (2)

isAlphaNumeric({ locale: 'pl-Pl' })
Input:
'ThisiZĄĆĘŚŁ1234'
Output:
'ThisiZĄĆĘŚŁ1234'

# Example (3)

isAlphaNumeric()
Input:
'not_alphanumeric.com'
Output:
null

# Example (4)

isAlphaNumeric()
Input:
true
Output:
null

isBase64

Type: FIELD_VALIDATION

Returns the input if it is a valid base64 string, otherwise returns null

Accepts

  • String

Examples

# Example (1)

isBase64()
Input:
'ZnJpZW5kbHlOYW1lNw=='
Output:
'ZnJpZW5kbHlOYW1lNw=='

# Example (2)

isBase64()
Input:
'manufacturerUrl7'
Output:
null

# Example (3)

isBase64()
Input:
1234123
Output:
null

isCountryCode

Type: FIELD_VALIDATION

Returns the input if it is a valid ISO 3166-1 alpha-2 country code, otherwise returns null

Accepts

  • String

Examples

# Example (1)

isCountryCode()
Input:
'US'
Output:
'US'

# Example (2)

isCountryCode()
Input:
'ZM'
Output:
'ZM'

# Example (3)

isCountryCode()
Input:
'GB'
Output:
'GB'

# Example (4)

isCountryCode()
Input:
'UK'
Output:
null

# Example (5)

isCountryCode()
Input:
12345
Output:
null

isEmail

Type: FIELD_VALIDATION

Returns the input if it is a valid email formatted string, otherwise returns null

Accepts

  • String

Examples

# Example (1)

isEmail()
Input:
'string@gmail.com'
Output:
'string@gmail.com'

# Example (2)

isEmail()
Input:
'non.us.email@thing.com.uk'
Output:
'non.us.email@thing.com.uk'

# Example (3)

isEmail()
Input:
'Abc@def@example.com'
Output:
'Abc@def@example.com'

# Example (4)

isEmail()
Input:
'cal+henderson@iamcalx.com'
Output:
'cal+henderson@iamcalx.com'

# Example (5)

isEmail()
Input:
'customer/department=shipping@example.com'
Output:
'customer/department=shipping@example.com'

# Example (6)

isEmail()
Input:
'user@blah.com/junk.junk?a=<tag value="junk"'
Output:
null

# Example (7)

isEmail()
Input:
'Abc@def  @  example.com'
Output:
null

# Example (8)

isEmail()
Input:
'bad email address'
Output:
null

# Example (9)

isEmail()
Input:
12345
Output:
null

isFQDN

Type: FIELD_VALIDATION

Returns the input if it is a fully qualified domain name, otherwise returns null

Accepts

  • String

Examples

# Example (1)

isFQDN()
Input:
'example.com'
Output:
'example.com'

# Example (2)

isFQDN()
Input:
'international-example.com.br'
Output:
'international-example.com.br'

# Example (3)

isFQDN()
Input:
'1234.com'
Output:
'1234.com'

# Example (4)

isFQDN()
Input:
'no_underscores.com'
Output:
null

# Example (5)

isFQDN()
Input:
'**.bad.domain.com'
Output:
null

# Example (6)

isFQDN()
Input:
'example.0'
Output:
null

# Example (7)

isFQDN()
Input:
12345
Output:
null

isHash

Type: FIELD_VALIDATION

Returns the input if it is a hashed value, otherwise returns null

Arguments

  • algo: (required) String - The hashing algorithm to check values against

Accepts

  • String

Examples

# Example (1)

isHash({ algo: 'sha256' })
Input:
'85031b6f407e7f25cf826193338f7a4c2dc8c8b5130f5ca2c69a66d9f5107e33'
Output:
'85031b6f407e7f25cf826193338f7a4c2dc8c8b5130f5ca2c69a66d9f5107e33'

# Example (2)

isHash({ algo: 'md5' })
Input:
'85031b6f407e7f25cf826193338f7a4c2dc8c8b5130f5ca2c69a66d9f5107e33'
Output:
null

isISDN

Type: FIELD_VALIDATION

Returns the input if it is a valid phone number. If the country arg is not provided then it is processed as an international formatted phone number

Arguments

  • country: String - A valid ISO 3166-1 alpha-2 officially assigned country code

Accepts

  • String
  • Number

Examples

# Example (1)

isISDN()
Input:
'46707123456'
Output:
'46707123456'

# Example (2)

isISDN()
Input:
'1-808-915-6800'
Output:
'1-808-915-6800'

# Example (3)

isISDN({ country: 'US' })
Input:
'8089156800'
Output:
'8089156800'

# Example (4)

isISDN()
Input:
'8089156800'
Output:
null

isLength

Type: FIELD_VALIDATION

Returns the input if it either matches a certain length, or is within the specified range. Otherwise returns null

Arguments

  • size: Number - The value's length must equal this parameter if specified

  • min: Number - The value's length must be greater than or equal to this parameter if specified

  • max: Number - The value's length must be less than or equal to this parameter if specified

Accepts

  • String

Examples

# Example (1)

isLength({ size: 8 })
Input:
'iam8char'
Output:
'iam8char'

# Example (2)

isLength({ size: 8 })
Input:
'iamnot8char'
Output:
null

# Example (3)

isLength({ min: 3 })
Input:
'aString'
Output:
'aString'

# Example (4)

isLength({ min: 3, max: 5 })
Input:
'aString'
Output:
null

# Example (5)

isLength({ min: 3, max: 5 })
Input:
4
Output:
null

isMACAddress

Type: FIELD_VALIDATION

Returns the input if it is a valid mac address, otherwise returns null

Arguments

  • delimiter: String - Specify delimiter character for the mac address format, may be set to one of space, colon, dash, dot, none and any

Accepts

  • String

Examples

# Example (1)

isMACAddress()
Input:
'00:1f:f3:5b:2b:1f'
Output:
'00:1f:f3:5b:2b:1f'

# Example (2)

isMACAddress()
Input:
'001ff35b2b1f'
Output:
'001ff35b2b1f'

# Example (3)

isMACAddress()
Input:
'00-1f-f3-5b-2b-1f'
Output:
'00-1f-f3-5b-2b-1f'

# Example (4)

isMACAddress({ delimiter: 'colon' })
Input:
'00-1f-f3-5b-2b-1f'
Output:
null

# Example (5)

isMACAddress({ delimiter: 'any' })
Input:
'00-1f-f3-5b-2b-1f'
Output:
'00-1f-f3-5b-2b-1f'

# Example (6)

isMACAddress({ delimiter: 'dash' })
Input:
'00-1f-f3-5b-2b-1f'
Output:
'00-1f-f3-5b-2b-1f'

# Example (7)

isMACAddress({ delimiter: 'dot' })
Input:
'001f.f35b.2b1f'
Output:
'001f.f35b.2b1f'

# Example (8)

isMACAddress({ delimiter: 'none' })
Input:
'001ff35b2b1f'
Output:
'001ff35b2b1f'

# Example (9)

isMACAddress()
Input:
'aString'
Output:
null

# Example (10)

isMACAddress()
Input:
4
Output:
null

isMIMEType

Type: FIELD_VALIDATION

Returns the input if it is a valid Media or MIME (Multipurpose Internet Mail Extensions) Type, otherwise returns null

Accepts

  • String

Examples

# Example (1)

isMIMEType()
Input:
'application/javascript'
Output:
'application/javascript'

# Example (2)

isMIMEType()
Input:
'text/html'
Output:
'text/html'

# Example (3)

isMIMEType()
Input:
'application'
Output:
null

# Example (4)

isMIMEType()
Input:
''
Output:
null

isPhoneNumberLike

Type: FIELD_VALIDATION

A simplified phone number check that returns the input if it has the basic requirements of a phone number, otherwise returns null. Useful if the phone number's country is not known

Accepts

  • String
  • Number

Examples

# Example (1)

isPhoneNumberLike()
Input:
'46707123456'
Output:
'46707123456'

# Example (2)

isPhoneNumberLike()
Input:
'1-808-915-6800'
Output:
'1-808-915-6800'

# Example (3)

isPhoneNumberLike()
Input:
'79525554602'
Output:
'79525554602'

# Example (4)

isPhoneNumberLike()
Input:
'223457823432432423324'
Output:
null

# Example (5)

isPhoneNumberLike()
Input:
'2234'
Output:
null

isPort

Type: FIELD_VALIDATION

Returns the input it it is a valid TCP or UDP port, otherwise returns null

Accepts

  • String
  • Number

Examples

# Example (1)

isPort()
Input:
'49151'
Output:
'49151'

# Example (2)

isPort()
Input:
'80'
Output:
'80'

# Example (3)

isPort()
Input:
'65536'
Output:
null

# Example (4)

isPort()
Input:
'not a port'
Output:
null

isPostalCode

Type: FIELD_VALIDATION

Returns the input if it is a valid postal code, otherwise returns null

Arguments

  • locale: String - Specify the locale to check for valid postal codes in specific regions, defaults to any if locale is not provided

Accepts

  • String
  • Number

Examples

# Example (1)

isPostalCode()
Input:
'85249'
Output:
'85249'

# Example (2)

isPostalCode({ locale: 'RU' })
Input:
'191123'
Output:
'191123'

# Example (3)

isPostalCode()
Input:
'bobsyouruncle'
Output:
null

# Example (4)

isPostalCode({ locale: 'CN' })
Input:
'this is not a postal code'
Output:
null

isString

Type: FIELD_VALIDATION

Returns the input if it is is a string, otherwise returns null

Accepts

  • String

Examples

# Example (1)

isString()
Input:
'this is a string'
Output:
'this is a string'

# Example (2)

isString()
Input:
'12345'
Output:
'12345'

# Example (3)

isString()
Input:
{ hello: 'i am an object' }
Output:
null

# Example (4)

isString()
Input:
1234
Output:
null

# Example (5)

isString()
Input:
[ '12345', 'some more stuff' ]
Output:
[ '12345', 'some more stuff' ]

isURL

Type: FIELD_VALIDATION

Returns the input if it is a valid url string, otherwise returns null

Accepts

  • String

Examples

# Example (1)

isURL()
Input:
'http://someurl.com.uk'
Output:
'http://someurl.com.uk'

# Example (2)

isURL()
Input:
'ftp://someurl.bom:8080?some=bar&hi=bob'
Output:
'ftp://someurl.bom:8080?some=bar&hi=bob'

# Example (3)

isURL()
Input:
'http://xn--fsqu00a.xn--3lr804guic'
Output:
'http://xn--fsqu00a.xn--3lr804guic'

# Example (4)

isURL()
Input:
'http://example.com/hello%20world'
Output:
'http://example.com/hello%20world'

# Example (5)

isURL()
Input:
'bob.com'
Output:
'bob.com'

# Example (6)

isURL()
Input:
'isthis_valid_uri.com'
Output:
null

# Example (7)

isURL()
Input:
'http://sthis valid uri.com'
Output:
null

# Example (8)

isURL()
Input:
'hello://validuri.com'
Output:
null

isUUID

Type: FIELD_VALIDATION

Returns the input if it is a valid UUID, otherwise returns null

Accepts

  • String

Examples

# Example (1)

isUUID()
Input:
'95ecc380-afe9-11e4-9b6c-751b66dd541e'
Output:
'95ecc380-afe9-11e4-9b6c-751b66dd541e'

# Example (2)

isUUID()
Input:
'123e4567-e89b-82d3-f456-426655440000'
Output:
'123e4567-e89b-82d3-f456-426655440000'

# Example (3)

isUUID()
Input:
'95ecc380:afe9:11e4:9b6c:751b66dd541e'
Output:
null

# Example (4)

isUUID()
Input:
'123e4567-e89b-x2d3-0456-426655440000'
Output:
null

# Example (5)

isUUID()
Input:
'randomstring'
Output:
null

startsWith

Type: FIELD_VALIDATION

Returns the input if it begins with the args value string. This is case-sensitive

Arguments

  • value: (required) String - The value that must match at the beginning of the input string

Accepts

  • String

Examples

# Example (1)

startsWith({ value: 'a' })
Input:
'apple'
Output:
'apple'

# Example (2)

startsWith({ value: 'a' })
Input:
'orange'
Output:
null

# Example (3)

startsWith({ value: 'so' })
Input:
'some word'
Output:
'some word'

# Example (4)

startsWith({ value: 'so' })
Input:
'other word'
Output:
null

# Example (5)

startsWith({ value: 't' })
Input:
'hat'
Output:
null

createID

Type: FIELD_TRANSFORM

Returns a hash encoded string from one or more values. You can optionally override the default hash encoding of "md5"

Arguments

  • hash: String - Which hashing algorithm to use, defaults to sha256

  • digest: String - Which hash digest to use, may be set to either "base64" or "hex", defaults to "hex"

Examples

Hashing algorithm defaults to md5

# Example (1)

createID()
Input:
'foo'
Output:
'acbd18db4cc2f85cedef654fccc4a4d8'

# Example (2)

createID()
Input:
[ 'foo1', 'bar1' ]
Output:
'ad3ffa6c042cdee09c226a0544215f6f'

# Example (3)

createID({ hash: 'sha256' })
Input:
[ 'foo1', 'bar1' ]
Output:
'62910cf6a9d2b270a7f51cc7fc30efe274c0cdf2c04f18ac0757843b1c4dade2'

decodeBase64

Type: FIELD_TRANSFORM

Returns the base64-decoded version of the input string

Accepts

  • String

Examples

# Example (1)

decodeBase64()
Input:
'c29tZSBzdHJpbmc='
Output:
'some string'

decodeHex

Type: FIELD_TRANSFORM

Returns the hexadecimal-decoded version of the input string

Accepts

  • String

Examples

# Example (1)

decodeHex()
Input:
'736f6d652076616c756520666f722068657820656e636f64696e67'
Output:
'some value for hex encoding'

decodeURL

Type: FIELD_TRANSFORM

Returns the url-decoded version of the input string

Accepts

  • String

Examples

# Example (1)

decodeURL()
Input:
'google.com%3Fq%3DHELLO%20AND%20GOODBYE'
Output:
'google.com?q=HELLO AND GOODBYE'

encode

Type: FIELD_TRANSFORM

Returns a hashed version of the input string. The hashing algorithm and digest must be specified in the args

Arguments

  • algo: (required) String - The hashing algorithm applied to the input

  • digest: String - The hash digest applied to the input, may be set to either "base64" or "hex", defaults to "hex". Only used when algorithm is not base64, hex, or url

Accepts

  • String

Examples

Hashing algorithm defaults to 256, and digest defaults to hex

# Example (1)

encode({ algo: 'sha256' })
Input:
'{ "some": "data" }'
Output:
'e43e698b8ee20f09ae4257e81d7c8ac5074cdda2a8aef8d6c00dbbe5b404f7e5'

# Example (2)

encode({ algo: 'md5' })
Input:
'{ "some": "data" }'
Output:
'7e33b72a611da99c7e9013dd44dbbdad'

# Example (3)

encode({ algo: 'url' })
Input:
'google.com?q=HELLO AND GOODBYE'
Output:
'google.com%3Fq%3DHELLO%20AND%20GOODBYE'

# Example (4)

encode({ algo: 'base64' })
Input:
'HELLO AND GOODBYE'
Output:
'SEVMTE8gQU5EIEdPT0RCWUU='

# Example (5)

encode({ algo: 'sha1', digest: 'base64' })
Input:
'{ "some": "data" }'
Output:
'6MsUBHluumd5onY3fM6ZpQKjZIE='

encodeBase64

Type: FIELD_TRANSFORM

Returns a base64 hashed version of the input string

Accepts

  • String

Examples

# Example (1)

encodeBase64()
Input:
'some string'
Output:
'c29tZSBzdHJpbmc='

encodeHex

Type: FIELD_TRANSFORM

Returns a hexadecimal hashed version of the input string

Accepts

  • String

Examples

# Example (1)

encodeHex()
Input:
'some value for hex encoding'
Output:
'736f6d652076616c756520666f722068657820656e636f64696e67'

encodeSHA

Type: FIELD_TRANSFORM

Returns a SHA encoded version of the input string. Specify the hash algorithm and digest with the args options

Arguments

  • hash: String - Which hashing algorithm to use, defaults to sha256

  • digest: String - Which hash digest to use, may be set to either "base64" or "hex", defaults to "hex"

Accepts

  • String

Examples

Hashing algorithm defaults to sha256, and digest defaults to hex

# Example (1)

encodeSHA()
Input:
'{ "some": "data" }'
Output:
'e43e698b8ee20f09ae4257e81d7c8ac5074cdda2a8aef8d6c00dbbe5b404f7e5'

# Example (2)

encodeSHA({ digest: 'base64' })
Input:
'{ "some": "data" }'
Output:
'5D5pi47iDwmuQlfoHXyKxQdM3aKorvjWwA275bQE9+U='

encodeSHA1

Type: FIELD_TRANSFORM

Returns a SHA1 encoded version of the input value

Arguments

  • digest: String - Hash digest to used, may be set to either "base64" or "hex", defaults to "hex"

Accepts

  • String

Examples

If the digest is not provided, it defaults to hex

# Example (1)

encodeSHA1()
Input:
'{ "some": "data" }'
Output:
'e8cb1404796eba6779a276377cce99a502a36481'

# Example (2)

encodeSHA1({ digest: 'base64' })
Input:
'{ "some": "data" }'
Output:
'6MsUBHluumd5onY3fM6ZpQKjZIE='

encodeURL

Type: FIELD_TRANSFORM

Returns a URL encoded version of the input value

Accepts

  • String

Examples

# Example (1)

encodeURL()
Input:
'google.com?q=HELLO AND GOODBYE'
Output:
'google.com%3Fq%3DHELLO%20AND%20GOODBYE'

entropy

Type: FIELD_TRANSFORM

Calculates the entropy of a given string

Arguments

  • algo: String - The algorithm to use, defaults to "shannon"

Accepts

  • String

Examples

# Example (1)

entropy()
Input:
'0123456789abcdef'
Output:
4

# Example (2)

entropy({ algo: 'shannon' })
Input:
'1223334444'
Output:
1.8464393446710154

# Example (3)

entropy({ algo: 'unknownAlgoName' })
Input:
'1223334444'
Throws

extract

Type: FIELD_TRANSFORM

Returns an extracted substring or an array of substrings from the input string

Arguments

  • regex: String - The regex expression to execute, if set, do not use "start/end"

  • start: String - The char that acts as the starting boundary for extraction, this is only used with end, not regex

  • end: String - The char that acts as the ending boundary for extraction, this is only used with start, not regex

  • global: Boolean - If set to true, it will return an array of all possible extractions, defaults to false

Accepts

  • String

Examples

# Example (1)

extract({ start: '<', end: '>' })
Input:
'<hello>'
Output:
'hello'

# Example (2)

extract({ regex: 'he.*' })
Input:
'hello'
Output:
'hello'

# Example (3)

extract({ regex: '/([A-Z]\\w+)/', global: true })
Input:
'Hello World some other things'
Output:
[ 'Hello', 'World' ]

# Example (4)

extract({ start: '<', end: '>', global: true })
Input:
'<hello> some stuff <world>'
Output:
[ 'hello', 'world' ]

join

Type: FIELD_TRANSFORM

Returns a string from an array of values joined by the delimiter

Arguments

  • delimiter: String - The char to join the strings

Accepts

  • String
  • Number
  • Boolean

Examples

# Example (1)

join()
Input:
[
'a', ' ', 's',
't', 'r', 'i',
'n', 'g'
]
Output:
'a string'

# Example (2)

join({ delimiter: ',' })
Input:
[ 'a string', 'found' ]
Output:
'a string,found'

# Example (3)

join({ delimiter: ' - ' })
Input:
[ 'a', 'stri', 'ng' ]
Output:
'a - stri - ng'

# Example (4)

join({ delimiter: ' ' })
Input:
'a string'
Output:
'a string'

# Example (5)

join({ delimiter: ':' })
Input:
[ 'foo', 1, true ]
Output:
'foo:1:true'

replaceLiteral

Type: FIELD_TRANSFORM

Returns a string with the searched value replaced by the replace value

Arguments

  • search: (required) String - The characters that will be replaced

  • replace: (required) String - The value that will replace what is set in search

Accepts

  • String

Examples

# Example (1)

replaceLiteral({ search: 'bob', replace: 'mel' })
Input:
'Hi bob'
Output:
'Hi mel'

Does not replace as it is not an exact match

# Example (2)

replaceLiteral({ search: 'bob', replace: 'mel' })
Input:
'Hi Bob'
Output:
'Hi Bob'

replaceRegex

Type: FIELD_TRANSFORM

Returns a string with the characters matched by the regex replaced with the args replace value

Arguments

  • regex: (required) String - The regex expression to execute

  • replace: String - The value that will replace what is found by the regex

  • ignoreCase: Boolean - Options flag for regex if it should ignore case, defaults to false

  • global: Boolean - Options flag for regex to execute as many instances as is found, defaults to false

Accepts

  • String

Examples

# Example (1)

replaceRegex({ regex: 's|e', replace: 'd' })
Input:
'somestring'
Output:
'domestring'

# Example (2)

replaceRegex({ regex: 's|e', replace: 'd', global: true })
Input:
'somestring'
Output:
'domddtring'

# Example (3)

replaceRegex({ regex: 'm|t', replace: 'W', global: true, ignoreCase: true })
Input:
'soMesTring'
Output:
'soWesWring'

# Example (4)

replaceRegex({ regex: '\\*', replace: '', global: true })
Input:
'a***a***a'
Output:
'aaa'

reverse

Type: FIELD_TRANSFORM

Returns the input string with its characters in reverse order

Accepts

  • String

Examples

# Example (1)

reverse()
Input:
'hello'
Output:
'olleh'

# Example (2)

reverse()
Input:
'more words'
Output:
'sdrow erom'

# Example (3)

reverse()
Input:
[ 'hello', 'more' ]
Output:
[ 'olleh', 'erom' ]

split

Type: FIELD_TRANSFORM

Returns an array based off the input split by the args delimiter, defaults to splitting by each character

Arguments

  • delimiter: String - The char used to identify where to split the string

Accepts

  • String

Examples

# Example (1)

split()
Input:
'astring'
Output:
[
'a', 's', 't',
'r', 'i', 'n',
'g'
]

Delimiter is not found so the whole input is returned

# Example (2)

split({ delimiter: ',' })
Input:
'astring'
Output:
[ 'astring' ]

# Example (3)

split({ delimiter: '-' })
Input:
'a-stri-ng'
Output:
[ 'a', 'stri', 'ng' ]

# Example (4)

split({ delimiter: ' ' })
Input:
'a string'
Output:
[ 'a', 'string' ]

toCamelCase

Type: FIELD_TRANSFORM

Converts multiple words into a single word joined with each starting character capitalized, excluding the first character which is always lowercase

Accepts

  • String

Examples

# Example (1)

toCamelCase()
Input:
'HELLO there'
Output:
'helloThere'

# Example (2)

toCamelCase()
Input:
'billy'
Output:
'billy'

# Example (3)

toCamelCase()
Input:
'Hey There'
Output:
'heyThere'

toISDN

Type: FIELD_TRANSFORM

Converts the input to the ISDN format, if it is a valid phone number. Otherwise returns null

Accepts

  • String
  • Number

Examples

# Example (1)

toISDN()
Input:
'+33-1-22-33-44-55'
Output:
'33122334455'

# Example (2)

toISDN()
Input:
'1(800)FloWErs'
Output:
'18003569377'

# Example (3)

toISDN()
Input:
4917600000000
Output:
'4917600000000'

# Example (4)

toISDN()
Input:
49187484
Output:
'49187484'

# Example (5)

toISDN()
Input:
'something'
Throws

toKebabCase

Type: FIELD_TRANSFORM

Converts one or more words into a single word joined by dashes

Accepts

  • String

Examples

# Example (1)

toKebabCase()
Input:
'HELLO there'
Output:
'hello-there'

# Example (2)

toKebabCase()
Input:
'billy'
Output:
'billy'

# Example (3)

toKebabCase()
Input:
'Hey There'
Output:
'hey-there'

toLowerCase

Type: FIELD_TRANSFORM

Converts a string to lower case characters

Accepts

  • String

Examples

# Example (1)

toLowerCase()
Input:
'HELLO there'
Output:
'hello there'

# Example (2)

toLowerCase()
Input:
'biLLy'
Output:
'billy'

toPascalCase

Type: FIELD_TRANSFORM

Converts one or more words into a single word joined with each starting character capitalized

Accepts

  • String

Examples

# Example (1)

toPascalCase()
Input:
'HELLO there'
Output:
'HelloThere'

# Example (2)

toPascalCase()
Input:
'billy'
Output:
'Billy'

# Example (3)

toPascalCase()
Input:
'Hey There'
Output:
'HeyThere'

toSnakeCase

Type: FIELD_TRANSFORM

Converts one or more words into a single word joined by underscores

Accepts

  • String

Examples

# Example (1)

toSnakeCase()
Input:
'HELLO there'
Output:
'hello_there'

# Example (2)

toSnakeCase()
Input:
'billy'
Output:
'billy'

# Example (3)

toSnakeCase()
Input:
'Hey There'
Output:
'hey_there'

toString

Type: FIELD_TRANSFORM

Converts the input value to a string. If the input is an array each array item will be converted to a string

Examples

# Example (1)

toString()
Input:
true
Output:
'true'

# Example (2)

toString()
Input:
{ hello: 'world' }
Output:
'{"hello":"world"}'

# Example (3)

toString()
Input:
278218429446951548637196401n
Output:
'278218429446951548637196400'

# Example (4)

toString()
Input:
[ true, false ]
Output:
[ 'true', 'false' ]

toTitleCase

Type: FIELD_TRANSFORM

Converts one or more words into a whitespace separated string with each word starting with a capital letter

Accepts

  • String

Examples

# Example (1)

toTitleCase()
Input:
'HELLO there'
Output:
'HELLO There'

# Example (2)

toTitleCase()
Input:
'billy'
Output:
'Billy'

# Example (3)

toTitleCase()
Input:
'Hey There'
Output:
'Hey There'

toUpperCase

Type: FIELD_TRANSFORM

Converts a string to upper case characters

Accepts

  • String

Examples

# Example (1)

toUpperCase()
Input:
'hello'
Output:
'HELLO'

# Example (2)

toUpperCase()
Input:
'billy'
Output:
'BILLY'

# Example (3)

toUpperCase()
Input:
'Hey There'
Output:
'HEY THERE'

trim

Type: FIELD_TRANSFORM

Trims whitespace or characters from the beginning and end of a string

Arguments

  • chars: String - The characters to remove, defaults to whitespace

Accepts

  • String

Examples

# Example (1)

trim()
Input:
'   other_things         '
Output:
'other_things'

# Example (2)

trim()
Input:
'Stuff        '
Output:
'Stuff'

# Example (3)

trim()
Input:
'      hello'
Output:
'hello'

# Example (4)

trim()
Input:
'       '
Output:
''

# Example (5)

trim()
Input:
'Spider Man'
Output:
'Spider Man'

# Example (6)

trim({ chars: 'a' })
Input:
'aaaaSpider Manaaaa'
Output:
'Spider Man'

Any new char, including whitespace will stop the trim, it must be consecutive

# Example (7)

trim({ chars: 'a' })
Input:
'aa aaSpider Manaa aa'
Output:
' aaSpider Manaa '

# Example (8)

trim({ chars: 'fast' })
Input:
'fast cars race fast'
Output:
' cars race '

# Example (9)

trim({ chars: 'fatc ' })
Input:
'fast example cata'
Output:
'st example'

# Example (10)

trim({ chars: '\r' })
Input:
'\t\r\rtrim this\r\r'
Output:
'\t\r\rtrim this'

# Example (11)

trim({ chars: '.*' })
Input:
'.*.*a test.*.*.*.*'
Output:
'a test'

trimEnd

Type: FIELD_TRANSFORM

Trims whitespace or characters from the end of a string

Arguments

  • chars: String - The characters to remove, defaults to whitespace

Accepts

  • String

Examples

# Example (1)

trimEnd()
Input:
'   left'
Output:
'   left'

# Example (2)

trimEnd()
Input:
'right   '
Output:
'right'

# Example (3)

trimEnd()
Input:
'       '
Output:
''

# Example (4)

trimEnd({ chars: '*' })
Input:
'*****Hello****Bob*****'
Output:
'*****Hello****Bob'

# Example (5)

trimEnd({ chars: 'fast' })
Input:
'fast cars race fast'
Output:
'fast cars race '

trimStart

Type: FIELD_TRANSFORM

Trims whitespace or characters from the start of a string

Arguments

  • chars: String - The characters to remove, defaults to whitespace

Accepts

  • String

Examples

# Example (1)

trimStart()
Input:
'    Hello Bob    '
Output:
'Hello Bob    '

# Example (2)

trimStart({ chars: '__--' })
Input:
'__--__--__some__--__word'
Output:
'some__--__word'

# Example (3)

trimStart()
Input:
'       '
Output:
''

# Example (4)

trimStart({ chars: '*' })
Input:
'*****Hello****Bob*****'
Output:
'Hello****Bob*****'

truncate

Type: FIELD_TRANSFORM

Limits the size of the input string to a specific length, if the length is greater than the specified size, the excess is removed

Arguments

  • size: (required) Number - How long the string should be

Accepts

  • String

Examples

# Example (1)

truncate({ size: 4 })
Input:
'thisisalongstring'
Output:
'this'

# Example (2)

truncate({ size: 8 })
Input:
'Hello world'
Output:
'Hello wo'

CATEGORY: Ip

isIP

Type: FIELD_VALIDATION

Returns the input if it is a valid IPv4 or IPv6 IP address. Accepts dot notation for IPv4 addresses and hexadecimal separated by colons for IPv6 addresses

Accepts

  • String
  • IP

Examples

# Example (1)

isIP()
Input:
'11.0.1.18'
Output:
'11.0.1.18'

# Example (2)

isIP()
Input:
'2001:db8:85a3:8d3:1319:8a2e:370:7348'
Output:
'2001:db8:85a3:8d3:1319:8a2e:370:7348'

# Example (3)

isIP()
Input:
'172.394.0.1'
Output:
null

# Example (4)

isIP()
Input:
1234567
Output:
null

# Example (5)

isIP()
Input:
'not an IP address'
Output:
null

inIPRange

Type: FIELD_VALIDATION

Returns the input if the IP is within the given range, boundaries are inclusive. Accepts min, max or cidr notation for the IP range, also accepts min without a max and vice versa

Arguments

  • min: String - IPv4 or IPv6 value, used for the bottom of the range, this value inclusive

  • max: String - IPv4 or IPv6 value, used for the top of the range, this value inclusive

  • cidr: String - IPv4 or IPv6 range expressed in CIDR notation, this value inclusive

Accepts

  • String
  • IP

Examples

# Example (1)

inIPRange({ cidr: '8.8.8.0/24' })
Input:
'8.8.8.8'
Output:
'8.8.8.8'

# Example (2)

inIPRange({ min: 'fd00::123', max: 'fd00::ea00' })
Input:
'fd00::b000'
Output:
'fd00::b000'

# Example (3)

inIPRange({ min: 'fd00::123' })
Input:
'fd00::b000'
Output:
'fd00::b000'

# Example (4)

inIPRange({ cidr: '8.8.8.0/24' })
Input:
'8.8.10.8'
Output:
null

isCIDR

Type: FIELD_VALIDATION

Returns the input if it is a valid IPv4 or IPv6 IP address in CIDR notation, otherwise returns null

Accepts

  • String
  • IPRange

Examples

# Example (1)

isCIDR()
Input:
'1.2.3.4/32'
Output:
'1.2.3.4/32'

# Example (2)

isCIDR()
Input:
'2001::1234:5678/128'
Output:
'2001::1234:5678/128'

# Example (3)

isCIDR()
Input:
'8.8.8.10'
Output:
null

# Example (4)

isCIDR()
Input:
'badIPAddress/24'
Output:
null

isIPv4

Type: FIELD_VALIDATION

Returns the input if it is a valid IPv4 address in dot notation, otherwise returns null

Accepts

  • String
  • IP

Examples

# Example (1)

isIPv4()
Input:
'11.0.1.18'
Output:
'11.0.1.18'

# Example (2)

isIPv4()
Input:
'2001:db8:85a3:8d3:1319:8a2e:370:7348'
Output:
null

# Example (3)

isIPv4()
Input:
'172.394.0.1'
Output:
null

# Example (4)

isIPv4()
Input:
'not an IP address'
Output:
null

isIPv6

Type: FIELD_VALIDATION

Returns the input if it is a valid IPv6 IP address in hexadecimal separated by colons format, otherwise returns null

Accepts

  • String
  • IP

Examples

# Example (1)

isIPv6()
Input:
'2001:db8:85a3:8d3:1319:8a2e:370:7348'
Output:
'2001:db8:85a3:8d3:1319:8a2e:370:7348'

# Example (2)

isIPv6()
Input:
'fc00:db8::1'
Output:
'fc00:db8::1'

# Example (3)

isIPv6()
Input:
'::FFFF:12.155.166.101'
Output:
'::FFFF:12.155.166.101'

# Example (4)

isIPv6()
Input:
'11.0.1.18'
Output:
null

# Example (5)

isIPv6()
Input:
'not an IP address'
Output:
null

isNonRoutableIP

Type: FIELD_VALIDATION

Returns the input if it is a non-routable IP address, handles IPv6 and IPv4 address. See https://www.iana.org/assignments/iana-ipv4-special-registry/iana-ipv4-special-registry.xhtml and https://www.iana.org/assignments/iana-ipv6-special-registry/iana-ipv6-special-registry.xhtml

Accepts

  • String
  • IP

Examples

# Example (1)

isNonRoutableIP()
Input:
'192.168.0.1'
Output:
'192.168.0.1'

# Example (2)

isNonRoutableIP()
Input:
'2001:db8::1'
Output:
'2001:db8::1'

# Example (3)

isNonRoutableIP()
Input:
'172.28.4.1'
Output:
'172.28.4.1'

# Example (4)

isNonRoutableIP()
Input:
'8.8.8.8'
Output:
null

# Example (5)

isNonRoutableIP()
Input:
'2001:2ff::ffff'
Output:
null

isRoutableIP

Type: FIELD_VALIDATION

Returns the input if it is a routable IPv4 or IPv6 address. See https://www.iana.org/assignments/iana-ipv4-special-registry/iana-ipv4-special-registry.xhtml and https://www.iana.org/assignments/iana-ipv6-special-registry/iana-ipv6-special-registry.xhtml

Accepts

  • String
  • IP

Examples

# Example (1)

isRoutableIP()
Input:
'8.8.8.8'
Output:
'8.8.8.8'

# Example (2)

isRoutableIP()
Input:
'2620:4f:123::'
Output:
'2620:4f:123::'

# Example (3)

isRoutableIP()
Input:
'192.168.255.254'
Output:
null

# Example (4)

isRoutableIP()
Input:
'2001:4:112::'
Output:
null

# Example (5)

isRoutableIP()
Input:
'not an IP address'
Output:
null

isMappedIPv4

Type: FIELD_VALIDATION

Returns the input if it is an IPv4 address mapped to an IPv6 address, otherwise returns null

Accepts

  • String
  • IP

Examples

# Example (1)

isMappedIPv4()
Input:
'::ffff:10.2.1.18'
Output:
'::ffff:10.2.1.18'

# Example (2)

isMappedIPv4()
Input:
'::122.168.5.18'
Output:
'::122.168.5.18'

# Example (3)

isMappedIPv4()
Input:
'10.16.32.210'
Output:
null

# Example (4)

isMappedIPv4()
Input:
'2001:4:112::'
Output:
null

# Example (5)

isMappedIPv4()
Input:
'not an IP address'
Output:
null

extractMappedIPv4

Type: FIELD_TRANSFORM

Extracts a mapped IPv4 address from an IPv6 address and returns the IPv4 address

Accepts

  • String
  • IP

Examples

# Example (1)

extractMappedIPv4()
Input:
'::FFFF:192.52.193.1'
Output:
'192.52.193.1'

# Example (2)

extractMappedIPv4()
Input:
'::122.168.5.18'
Output:
'122.168.5.18'

reverseIP

Type: FIELD_TRANSFORM

Returns the IP address in reverse notation, accepts both IPv4 and IPv6 addresses

Accepts

  • String
  • IP

Examples

# Example (1)

reverseIP()
Input:
'10.16.32.210'
Output:
'210.32.16.10'

# Example (2)

reverseIP()
Input:
'2001:0db8:0000:0000:0000:8a2e:0370:7334'
Output:
'4.3.3.7.0.7.3.0.e.2.a.8.0.0.0.0.0.0.0.0.0.0.0.0.8.b.d.0.1.0.0.2'

# Example (3)

reverseIP()
Input:
'2001:2::'
Output:
'0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.2.0.0.0.1.0.0.2'

ipToInt

Type: FIELD_TRANSFORM

Returns the IP as an integer or a big int

Accepts

  • String
  • IP

Examples

# Example (1)

ipToInt()
Input:
'10.16.32.210'
Output:
168829138

# Example (2)

ipToInt()
Input:
'2001:2::'
Output:
'42540488320432167789079031612388147199'

intToIP

Type: FIELD_TRANSFORM

Converts an integer to an IP address, must provide the version of the returned IP address

Arguments

  • version: (required) Any - Which version of IP to create, 4 => IPv4, 6 => IPv6

Accepts

  • String
  • Number

Examples

# Example (1)

intToIP({ version: 4 })
Input:
168829138
Output:
'10.16.32.210'

# Example (2)

intToIP({ version: '6' })
Input:
'42540488320432167789079031612388147200'
Output:
'2001:2::'

getCIDRMin

Type: FIELD_TRANSFORM

Returns the first address of a CIDR range, excluding the network address

Accepts

  • String
  • IPRange

Examples

# Example (1)

getCIDRMin()
Input:
'8.8.12.118/24'
Output:
'8.8.12.1'

# Example (2)

getCIDRMin()
Input:
'2001:0db8:0123:4567:89ab:cdef:1234:5678/128'
Output:
'2001:db8:123:4567:89ab:cdef:1234:5678'

# Example (3)

getCIDRMin()
Input:
'2001:0db8:0123:4567:89ab:cdef:1234:5678/46'
Output:
'2001:db8:120::1'

getCIDRMax

Type: FIELD_TRANSFORM

Returns the last address of a CIDR range, excluding the broadcast address for IPv4 addresses

Accepts

  • String
  • IPRange

Examples

# Example (1)

getCIDRMax()
Input:
'8.8.12.118/24'
Output:
'8.8.12.254'

# Example (2)

getCIDRMax()
Input:
'2001:0db8:0123:4567:89ab:cdef:1234:5678/128'
Output:
'2001:db8:123:4567:89ab:cdef:1234:5678'

# Example (3)

getCIDRMax()
Input:
'2001:0db8:0123:4567:89ab:cdef:1234:5678/46'
Output:
'2001:db8:123:ffff:ffff:ffff:ffff:ffff'

getCIDRBroadcast

Type: FIELD_TRANSFORM

Returns the broadcast address of a CIDR range, only applicable to IPv4 addresses

Accepts

  • String
  • IPRange

Examples

# Example (1)

getCIDRBroadcast()
Input:
'8.8.12.118/24'
Output:
'8.8.12.255'

# Example (2)

getCIDRBroadcast()
Input:
'1.2.3.4/32'
Output:
'1.2.3.4'

getCIDRNetwork

Type: FIELD_TRANSFORM

Returns the network address of a CIDR range, only applicable to IPv4 addresses

Accepts

  • String
  • IPRange

Examples

# Example (1)

getCIDRNetwork()
Input:
'8.8.12.118/24'
Output:
'8.8.12.0'

# Example (2)

getCIDRNetwork()
Input:
'1.2.3.4/32'
Output:
'1.2.3.4'

toCIDR

Type: FIELD_TRANSFORM

Returns a CIDR address based on the provided IP and suffix

Arguments

  • suffix: (required) Any - Suffix must be between 0 and 32 for IPv4 address and 0 and 128 for IPv6 addresses

Accepts

  • String
  • IP

Examples

# Example (1)

toCIDR({ suffix: 32 })
Input:
'1.2.3.4'
Output:
'1.2.3.4/32'

# Example (2)

toCIDR({ suffix: 24 })
Input:
'1.2.3.4'
Output:
'1.2.3.0/24'

# Example (3)

toCIDR({ suffix: '46' })
Input:
'2001:0db8:0123:4567:89ab:cdef:1234:5678'
Output:
'2001:db8:120::/46'