Data-Mate Functions
CATEGORY: Boolean
isBoolean
Type: FIELD_VALIDATION
Returns the input if it is a boolean, otherwise returns null
Examples
# Example (1)
isBoolean()
'TRUE'
null
# Example (2)
isBoolean()
false
false
# Example (3)
isBoolean()
1
null
# Example (4)
isBoolean()
102
null
# Example (5)
isBoolean()
'example'
null
isBooleanLike
Type: FIELD_VALIDATION
Returns the input if it can be converted to a boolean, otherwise returns null
Examples
# Example (1)
isBooleanLike()
'TRUE'
'TRUE'
# Example (2)
isBooleanLike()
'false'
'false'
# Example (3)
isBooleanLike()
1
1
# Example (4)
isBooleanLike()
102
null
# Example (5)
isBooleanLike()
'example'
null
toBoolean
Type: FIELD_TRANSFORM
Converts the input into a boolean and returns the boolean value
Examples
# Example (1)
toBoolean()
'TRUE'
true
# Example (2)
toBoolean()
1
true
# Example (3)
toBoolean()
0
false
# Example (4)
toBoolean()
null
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' })
'33.435518,-111.873616'
'33.435518,-111.873616'
# Example (2)
geoContains({ value: { type: 'Point', coordinates: [ -111.873616, 33.435518 ] } })
'45.518,-21.816'
null
# Example (3)
geoContains({ value: [ '10,10', '10,50', '50,50', '50,10', '10,10' ] })
{
type: 'Polygon',
coordinates: [ [ [ 0, 0 ], [ 100, 0 ], [ 100, 60 ], [ 0, 60 ], [ 0, 0 ] ] ]
}
{
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 ]
]
]
]
}
})
{
type: 'MultiPolygon',
coordinates: [
[ [ [ 10, 10 ], [ 10, 50 ], [ 50, 50 ], [ 50, 10 ], [ 10, 10 ] ] ],
[
[
[ -10, -10 ],
[ -10, -50 ],
[ -50, -50 ],
[ -50, -10 ],
[ -10, -10 ]
]
]
]
}
{
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 ] } })
{
type: 'MultiPolygon',
coordinates: [
[ [ [ 10, 10 ], [ 10, 20 ], [ 20, 20 ], [ 20, 10 ], [ 10, 10 ] ] ],
[ [ [ 30, 30 ], [ 30, 40 ], [ 40, 40 ], [ 40, 30 ], [ 30, 30 ] ] ]
]
}
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' })
'33.435967,-111.867710'
'33.435967,-111.867710'
# Example (2)
geoPointWithinRange({ point: '33.435518,-111.873616', distance: '5000m' })
'22.435967,-150.867710'
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' ] })
'-33.435967,-111.867710'
'-33.435967,-111.867710'
# Example (2)
geoDisjoint({ value: [ '10,10', '10,50', '50,50', '50,10', '10,10' ] })
{ type: 'Point', coordinates: [ 20, 20 ] }
null
# Example (3)
geoDisjoint({
value: {
type: 'Polygon',
coordinates: [ [ [ 0, 0 ], [ 0, 15 ], [ 15, 15 ], [ 15, 0 ], [ 0, 0 ] ] ]
}
})
{
type: 'Polygon',
coordinates: [ [ [ 20, 20 ], [ 20, 30 ], [ 30, 30 ], [ 30, 20 ], [ 20, 20 ] ] ]
}
{
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 ] ] ]
}
})
{
type: 'MultiPolygon',
coordinates: [
[ [ [ 10, 10 ], [ 10, 50 ], [ 50, 50 ], [ 50, 10 ], [ 10, 10 ] ] ],
[
[
[ -10, -10 ],
[ -10, -50 ],
[ -50, -50 ],
[ -50, -10 ],
[ -10, -10 ]
]
]
]
}
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' ] })
{ type: 'Point', coordinates: [ 20, 20 ] }
{ type: 'Point', coordinates: [ 20, 20 ] }
# Example (2)
geoIntersects({ value: [ '10,10', '10,50', '50,50', '50,10', '10,10' ] })
{
type: 'Polygon',
coordinates: [ [ [ 0, 0 ], [ 0, 15 ], [ 15, 15 ], [ 15, 0 ], [ 0, 0 ] ] ]
}
{
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 ] ] ]
}
})
{
type: 'MultiPolygon',
coordinates: [
[ [ [ 10, 10 ], [ 10, 50 ], [ 50, 50 ], [ 50, 10 ], [ 10, 10 ] ] ],
[
[
[ -10, -10 ],
[ -10, -50 ],
[ -50, -50 ],
[ -50, -10 ],
[ -10, -10 ]
]
]
]
}
{
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' ] })
'20,20'
'20,20'
# Example (2)
geoRelation({
value: [ '10,10', '10,50', '50,50', '50,10', '10,10' ],
relation: 'within'
})
'20,20'
'20,20'
# Example (3)
geoRelation({
value: [ '10,10', '10,50', '50,50', '50,10', '10,10' ],
relation: 'contains'
})
'20,20'
null
# Example (4)
geoRelation({
value: {
type: 'Polygon',
coordinates: [ [ [ 0, 0 ], [ 0, 15 ], [ 15, 15 ], [ 15, 0 ], [ 0, 0 ] ] ]
},
relation: 'disjoint'
})
{
type: 'Polygon',
coordinates: [ [ [ 20, 20 ], [ 20, 30 ], [ 30, 30 ], [ 30, 20 ], [ 20, 20 ] ] ]
}
{
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'
})
{
type: 'Polygon',
coordinates: [ [ [ 0, 0 ], [ 0, 15 ], [ 15, 15 ], [ 15, 0 ], [ 0, 0 ] ] ]
}
{
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'
})
{
type: 'Polygon',
coordinates: [ [ [ 0, 0 ], [ 0, 15 ], [ 15, 15 ], [ 15, 0 ], [ 0, 0 ] ] ]
}
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' ] })
{ type: 'Point', coordinates: [ 20, 20 ] }
{ type: 'Point', coordinates: [ 20, 20 ] }
# Example (2)
geoWithin({ value: [ '10,10', '10,50', '50,50', '50,10', '10,10' ] })
'20,20'
'20,20'
# Example (3)
geoWithin({ value: [ '10,10', '10,50', '50,50', '50,10', '10,10' ] })
{
type: 'Polygon',
coordinates: [ [ [ 20, 20 ], [ 20, 30 ], [ 30, 30 ], [ 30, 20 ], [ 20, 20 ] ] ]
}
{
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 ]
]
]
]
}
})
{
type: 'MultiPolygon',
coordinates: [
[ [ [ 10, 10 ], [ 10, 50 ], [ 50, 50 ], [ 50, 10 ], [ 10, 10 ] ] ],
[
[
[ -10, -10 ],
[ -10, -50 ],
[ -50, -50 ],
[ -50, -10 ],
[ -10, -10 ]
]
]
]
}
{
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 ]
]
]
]
}
})
{
type: 'MultiPolygon',
coordinates: [
[ [ [ 10, 10 ], [ 10, 20 ], [ 20, 20 ], [ 20, 10 ], [ 10, 10 ] ] ],
[ [ [ 30, 30 ], [ 30, 40 ], [ 40, 40 ], [ 40, 30 ], [ 30, 30 ] ] ]
]
}
{
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' })
{
type: 'Polygon',
coordinates: [ [ [ 10, 10 ], [ 10, 50 ], [ 50, 50 ], [ 50, 10 ], [ 10, 10 ] ] ]
}
{
type: 'Polygon',
coordinates: [ [ [ 10, 10 ], [ 10, 50 ], [ 50, 50 ], [ 50, 10 ], [ 10, 10 ] ] ]
}
# Example (2)
geoContainsPoint({ point: '15, 15' })
{
type: 'MultiPolygon',
coordinates: [
[ [ [ 10, 10 ], [ 10, 50 ], [ 50, 50 ], [ 50, 10 ], [ 10, 10 ] ] ],
[
[
[ -10, -10 ],
[ -10, -50 ],
[ -50, -50 ],
[ -50, -10 ],
[ -10, -10 ]
]
]
]
}
{
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' })
{
type: 'Polygon',
coordinates: [
[
[ -10, -10 ],
[ -10, -50 ],
[ -50, -50 ],
[ -50, -10 ],
[ -10, -10 ]
],
[
[ -20, -20 ],
[ -20, -40 ],
[ -40, -40 ],
[ -40, -20 ],
[ -20, -20 ]
]
]
}
null
Point is within a polygon with holes
# Example (4)
geoContainsPoint({ point: '15, 15' })
{
type: 'Polygon',
coordinates: [
[ [ 10, 10 ], [ 10, 50 ], [ 50, 50 ], [ 50, 10 ], [ 10, 10 ] ],
[ [ 20, 20 ], [ 20, 40 ], [ 40, 40 ], [ 40, 20 ], [ 20, 20 ] ]
]
}
{
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' })
{ type: 'Point', coordinates: [ 15, 15 ] }
{ 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'
})
'33.2,-112.3'
'33.2,-112.3'
# Example (2)
inGeoBoundingBox({
top_left: '33.906320,-112.758421',
bottom_right: '32.813646,-111.058902'
})
'43,-132'
null
# Example (3)
inGeoBoundingBox({
top_left: '33.906320,-112.758421',
bottom_right: '32.813646,-111.058902'
})
{ type: 'Point', coordinates: [ -112, 33 ] }
{ 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()
'60,40'
null
# Example (2)
isGeoJSON()
{ lat: 60, lon: 40 }
null
# Example (3)
isGeoJSON()
{ type: 'Point', coordinates: [ 12, 12 ] }
{ type: 'Point', coordinates: [ 12, 12 ] }
# Example (4)
isGeoJSON()
{
type: 'Polygon',
coordinates: [ [ [ 0, 0 ], [ 0, 15 ], [ 15, 15 ], [ 15, 0 ], [ 0, 0 ] ] ]
}
{
type: 'Polygon',
coordinates: [ [ [ 0, 0 ], [ 0, 15 ], [ 15, 15 ], [ 15, 0 ], [ 0, 0 ] ] ]
}
# Example (5)
isGeoJSON()
{
type: 'MultiPolygon',
coordinates: [
[ [ [ 10, 10 ], [ 10, 50 ], [ 50, 50 ], [ 50, 10 ], [ 10, 10 ] ] ],
[
[
[ -10, -10 ],
[ -10, -50 ],
[ -50, -50 ],
[ -50, -10 ],
[ -10, -10 ]
]
]
]
}
{
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()
'60,40'
'60,40'
# Example (2)
isGeoPoint()
[ 60, 40 ]
[ 60, 40 ]
# Example (3)
isGeoPoint()
{ lat: 60, lon: 40 }
{ lat: 60, lon: 40 }
# Example (4)
isGeoPoint()
{ latitude: 60, longitude: 40 }
{ latitude: 60, longitude: 40 }
# Example (5)
isGeoPoint()
'something'
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()
{ type: 'Point', coordinates: [ 12, 12 ] }
null
# Example (2)
isGeoShapeMultiPolygon()
{
type: 'Polygon',
coordinates: [ [ [ 10, 10 ], [ 10, 50 ], [ 50, 50 ], [ 50, 10 ], [ 10, 10 ] ] ]
}
null
# Example (3)
isGeoShapeMultiPolygon()
{
type: 'MultiPolygon',
coordinates: [
[ [ [ 10, 10 ], [ 10, 50 ], [ 50, 50 ], [ 50, 10 ], [ 10, 10 ] ] ],
[
[
[ -10, -10 ],
[ -10, -50 ],
[ -50, -50 ],
[ -50, -10 ],
[ -10, -10 ]
]
]
]
}
{
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()
{ type: 'Point', coordinates: [ 12, 12 ] }
{ type: 'Point', coordinates: [ 12, 12 ] }
# Example (2)
isGeoShapePoint()
{
type: 'Polygon',
coordinates: [ [ [ 10, 10 ], [ 10, 50 ], [ 50, 50 ], [ 50, 10 ], [ 10, 10 ] ] ]
}
null
# Example (3)
isGeoShapePoint()
{
type: 'MultiPolygon',
coordinates: [
[ [ [ 10, 10 ], [ 10, 50 ], [ 50, 50 ], [ 50, 10 ], [ 10, 10 ] ] ],
[
[
[ -10, -10 ],
[ -10, -50 ],
[ -50, -50 ],
[ -50, -10 ],
[ -10, -10 ]
]
]
]
}
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()
{ type: 'Point', coordinates: [ 12, 12 ] }
null
# Example (2)
isGeoShapePolygon()
{
type: 'Polygon',
coordinates: [ [ [ 10, 10 ], [ 10, 50 ], [ 50, 50 ], [ 50, 10 ], [ 10, 10 ] ] ]
}
{
type: 'Polygon',
coordinates: [ [ [ 10, 10 ], [ 10, 50 ], [ 50, 50 ], [ 50, 10 ], [ 10, 10 ] ] ]
}
# Example (3)
isGeoShapePolygon()
{
type: 'MultiPolygon',
coordinates: [
[ [ [ 10, 10 ], [ 10, 50 ], [ 50, 50 ], [ 50, 10 ], [ 10, 10 ] ] ],
[
[
[ -10, -10 ],
[ -10, -50 ],
[ -50, -50 ],
[ -50, -10 ],
[ -10, -10 ]
]
]
]
}
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()
'60,40'
{ type: 'Point', coordinates: [ 40, 60 ] }
# Example (2)
toGeoJSON()
[ '10,10', '10,50', '50,50', '50,10', '10,10' ]
{
type: 'Polygon',
coordinates: [ [ [ 10, 10 ], [ 50, 10 ], [ 50, 50 ], [ 10, 50 ], [ 10, 10 ] ] ]
}
# Example (3)
toGeoJSON()
{
type: 'MultiPolygon',
coordinates: [
[ [ [ 10, 10 ], [ 10, 50 ], [ 50, 50 ], [ 50, 10 ], [ 10, 10 ] ] ],
[
[
[ -10, -10 ],
[ -10, -50 ],
[ -50, -50 ],
[ -50, -10 ],
[ -10, -10 ]
]
]
]
}
{
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()
'60,40'
{ lon: 40, lat: 60 }
# Example (2)
toGeoPoint()
{ latitude: 40, longitude: 60 }
{ lon: 60, lat: 40 }
# Example (3)
toGeoPoint()
[ 50, 60 ]
{ lon: 50, lat: 60 }
# Example (4)
toGeoPoint()
'not an geo point'
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 theis_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' })
'21.223'
21
# Example (2)
cast({ type: 'Integer', array: true })
'21.223'
[ 21 ]
# Example (3)
cast({ type: 'Object', child_config: { foo: { type: 'Integer' } } })
{ foo: '21.23' }
{ 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' })
null
'example'
# Example (2)
setDefault({ value: 'example' })
null
[ 'example' ]
toJSON
Type: FIELD_TRANSFORM
Converts whole input to JSON format
Examples
# Example (1)
toJSON()
278218429446951548637196401n
'278218429446951548637196400'
# Example (2)
toJSON()
false
'false'
# Example (3)
toJSON()
{ some: 1234 }
'{"some":1234}'
# Example (4)
toJSON()
{ bigNum: 278218429446951548637196401n }
'{"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
or1h+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' })
'2019-10-22T22:00:00.000Z'
'2019-10-23T08:02:00.000Z'
# Example (2)
addToDate({ months: 1, minutes: 2 })
'2019-10-22T22:00:00.000Z'
'2019-11-22T22:02:00.000Z'
# Example (3)
addToDate()
'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 })
'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' })
'2019-10-22T00:00:00.000Z'
'2019-10-22'
# Example (2)
formatDate()
102390933
'1970-01-02T04:26:30.933Z'
# Example (3)
formatDate({ format: 'milliseconds' })
'1973-03-31T01:55:33.000Z'
102390933000
# Example (4)
formatDate()
'2001-01-01T01:00:00.000Z'
'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()
'2021-05-11T10:12:41.091Z'
11
# Example (2)
getDate()
2021-05-16T10:59:19.091Z
16
# Example (3)
getDate()
'05/22/2021 EST'
22
# Example (4)
getDate()
1510123223231
8
getHours
Type: FIELD_TRANSFORM
Returns the hours of the input date in UTC Time
Accepts
Date
String
Number
Examples
# Example (1)
getHours()
'2021-05-10T10:12:41.091Z'
10
# Example (2)
getHours()
2021-05-10T10:59:19.091Z
10
# Example (3)
getHours()
'05/22/2021 EST'
5
# Example (4)
getHours()
17154123223231
2
getMilliseconds
Type: FIELD_TRANSFORM
Returns the milliseconds of the input date
Accepts
Date
String
Number
Examples
# Example (1)
getMilliseconds()
'2021-05-10T10:00:01.091Z'
91
# Example (2)
getMilliseconds()
2021-05-10T10:00:01.091Z
91
# Example (3)
getMilliseconds()
1715472000231
231
getMinutes
Type: FIELD_TRANSFORM
Returns the minutes of the input date in UTC time
Accepts
Date
String
Number
Examples
# Example (1)
getMinutes()
'2021-05-10T10:12:41.091Z'
12
# Example (2)
getMinutes()
2021-05-10T10:59:19.091Z
59
# Example (3)
getMinutes()
1715472323231
5
getMonth
Type: FIELD_TRANSFORM
Returns the month of the input date in UTC Time
Accepts
Date
String
Number
Examples
# Example (1)
getMonth()
'2021-05-11T10:12:41.091Z'
5
# Example (2)
getMonth()
2021-05-16T10:59:19.091Z
5
# Example (3)
getMonth()
'05/22/2021 EST'
5
# Example (4)
getMonth()
1510123223231
11
getSeconds
Type: FIELD_TRANSFORM
Returns the seconds of the input date
Accepts
Date
String
Number
Examples
# Example (1)
getSeconds()
'2021-05-10T10:00:41.091Z'
41
# Example (2)
getSeconds()
2021-05-10T10:00:19.091Z
19
# Example (3)
getSeconds()
1715472323231
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' })
2021-05-10T10:00:01.000Z
1000
# Example (2)
getTimeBetween({ end: '2021-05-10T10:00:00.000Z', interval: 'days' })
'2021-05-09T10:00:00.000Z'
1
# Example (3)
getTimeBetween({ end: 1620764441001, interval: 'seconds' })
1620764440001
1
# Example (4)
getTimeBetween({ end: '2023-01-09T18:19:23.132Z', interval: 'ISO8601' })
'2021-05-10T10:00:00.000Z'
'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' })
2021-05-20T15:13:52.131Z
0
# Example (2)
getTimezoneOffset({ timezone: 'America/Anchorage' })
2021-05-20T15:13:52.131Z
-480
# Example (3)
getTimezoneOffset({ timezone: 'America/Aruba' })
2021-05-20T15:13:52.131Z
-240
# Example (4)
getTimezoneOffset({ timezone: 'Asia/Istanbul' })
2021-05-20T15:13:52.131Z
180
# Example (5)
getTimezoneOffset({ timezone: 'Australia/Canberra' })
2021-05-20T15:13:52.131Z
600
getYear
Type: FIELD_TRANSFORM
Returns the year of the input date in UTC Time
Accepts
Date
String
Number
Examples
# Example (1)
getYear()
'2021-05-11T10:12:41.091Z'
2021
# Example (2)
getYear()
2021-05-16T10:59:19.091Z
2021
# Example (3)
getYear()
'05/22/2021 EST'
2021
# Example (4)
getYear()
1510123223231
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()
'33.385765, -111.891167'
'America/Phoenix'
In ocean outside Morocco
# Example (2)
lookupTimezone()
'30.00123,-12.233'
'Etc/GMT+1'
# Example (3)
lookupTimezone()
[ 30.00123, 12.233 ]
'Africa/Khartoum'
# Example (4)
lookupTimezone()
{ lat: 48.86168702148502, lon: 2.3366209636711 }
'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 })
'2021-05-14T20:45:30.000Z'
'2021-05-12T20:45:30.000Z'
# Example (2)
setDate({ value: 22 })
2021-05-14T20:45:30.091Z
'2021-05-22T20:45:30.091Z'
# Example (3)
setDate({ value: 1 })
1715472000000
'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 })
'2021-05-14T20:45:30.000Z'
'2021-05-14T12:45:30.000Z'
# Example (2)
setHours({ value: 22 })
2021-05-14T20:45:30.091Z
'2021-05-14T22:45:30.091Z'
# Example (3)
setHours({ value: 1 })
1715472000000
'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 })
'2021-05-14T20:45:30.000Z'
'2021-05-14T20:45:30.392Z'
# Example (2)
setMilliseconds({ value: 483 })
2021-05-14T20:45:30.091Z
'2021-05-14T20:45:30.483Z'
# Example (3)
setMilliseconds({ value: 1 })
1715472000000
'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 })
'2021-05-14T20:45:30.000Z'
'2021-05-14T20:12:30.000Z'
# Example (2)
setMinutes({ value: 22 })
2021-05-14T20:45:30.091Z
'2021-05-14T20:22:30.091Z'
# Example (3)
setMinutes({ value: 1 })
1715472000000
'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 })
'2021-05-14T20:45:30.000Z'
'2021-12-14T20:45:30.000Z'
# Example (2)
setMonth({ value: 2 })
2021-05-14T20:45:30.091Z
'2021-02-14T20:45:30.091Z'
# Example (3)
setMonth({ value: 1 })
1715472000000
'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 })
'2021-05-14T20:45:30.000Z'
'2021-05-14T20:45:12.000Z'
# Example (2)
setSeconds({ value: 22 })
2021-05-14T20:45:30.091Z
'2021-05-14T20:45:22.091Z'
# Example (3)
setSeconds({ value: 1 })
1715472000000
'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 })
'2021-05-14T20:45:30.000Z'
'2021-05-14T20:45:30.000+07:00'
# Example (2)
setTimezone({ timezone: 'America/Phoenix' })
'2021-05-14T20:45:30.000Z'
'2021-05-14T20:45:30.000-07:00'
# Example (3)
setTimezone({ timezone: 120 })
'2020-02-14T20:45:30.091Z'
'2020-02-14T20:45:30.091+02:00'
# Example (4)
setTimezone({ timezone: 'Europe/Paris' })
'2020-02-14T20:45:30.091Z'
'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 })
'2021-05-14T20:45:30.000Z'
'2024-05-14T20:45:30.000Z'
# Example (2)
setYear({ value: 1984 })
2021-05-14T20:45:30.091Z
'1984-05-14T20:45:30.091Z'
# Example (3)
setYear({ value: 2023 })
[ 1621026000000, 420 ]
'2023-05-14T14:00:00.000Z'
# Example (4)
setYear({ value: 2001 })
1715472000000
'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
or1h+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' })
'2019-10-22T22:00:00.000Z'
'2019-10-22T12:02:00.000Z'
# Example (2)
subtractFromDate({ months: 1, minutes: 2 })
'2019-10-22T22:00:00.000Z'
'2019-09-22T21:58:00.000Z'
# Example (3)
subtractFromDate()
'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 })
'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()
'America/Phoenix'
-420
toDailyDate
Type: FIELD_TRANSFORM
Converts a value to a daily ISO 8601 date segment
Accepts
String
Number
Date
Examples
# Example (1)
toDailyDate()
'2019-10-22T01:00:00.000Z'
'2019-10-22T00:00:00.000Z'
# Example (2)
toDailyDate()
[ 1571706000000, 60 ]
'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' })
'2019-10-22'
'2019-10-22T00:00:00.000Z'
# Example (2)
toDate()
102390933
'1970-01-02T04:26:30.933Z'
# Example (3)
toDate({ format: 'seconds' })
102390933
'1973-03-31T01:55:33.000Z'
# Example (4)
toDate({ format: 'milliseconds' })
102390933000
'1973-03-31T01:55:33.000Z'
# Example (5)
toDate()
'2001-01-01T01:00:00.000Z'
'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()
'2019-10-22T01:05:20.000Z'
'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()
'2019-10-22T01:00:00.000Z'
'2019-10-01T00:00:00.000Z'
# Example (2)
toMonthlyDate()
[ 1571706000000, 120 ]
'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()
'2019-10-22T01:00:00.000Z'
'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' })
'2021-05-10T10:00:00.000Z'
'2021-05-10T10:00:00.000Z'
# Example (2)
isAfter({ date: 1620554400000 })
'2021-05-10T10:00:00.000Z'
'2021-05-10T10:00:00.000Z'
# Example (3)
isAfter({ date: '2021-05-09T10:00:00.000Z' })
1620640800000
1620640800000
# Example (4)
isAfter({ date: '2021-05-10T10:00:00.000Z' })
'2021-05-09T10:00:00.000Z'
null
# Example (5)
isAfter({ date: [ 1620640800000, -420 ] })
'2021-05-10T10:00:00.000Z'
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' })
'2021-05-09T10:00:00.000Z'
'2021-05-09T10:00:00.000Z'
# Example (2)
isBefore({ date: '2021-05-10T10:00:00.000Z' })
1620554400000
1620554400000
# Example (3)
isBefore({ date: 1620640800000 })
'2021-05-09T10:00:00.000Z'
'2021-05-09T10:00:00.000Z'
# Example (4)
isBefore({ date: '2021-05-10T10:00:00.000Z' })
'2021-05-11T10:00:00.000Z'
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' })
'2021-05-10T10:00:00.001Z'
'2021-05-10T10:00:00.001Z'
# Example (2)
isBetween({ start: 1620554400000, end: 1620640800000 })
1620554401000
1620554401000
# Example (3)
isBetween({ start: '2021-05-09T10:00:00.001Z', end: '2021-05-11T10:00:00.001Z' })
'2021-05-07T10:00:00.000Z'
null
# Example (4)
isBetween({ start: '2021-05-09T10:00:00.001Z', end: '2021-05-11T10:00:00.001Z' })
'2021-05-15T10:00:00.000Z'
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' })
'2019-10-22'
'2019-10-22'
# Example (2)
isDate({ format: 'yyyy-MM-dd' })
'10-22-2019'
null
# Example (3)
isDate({ format: 'epoch' })
102390933
102390933
# Example (4)
isDate()
'2001-01-01T01:00:00.000Z'
'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()
'2019-10-22'
null
# Example (2)
isEpoch()
102390933
102390933
# Example (3)
isEpoch()
'2001-01-01T01:00:00.000Z'
null
# Example (4)
isEpoch({ allowBefore1970: false })
-102390933
null
# Example (5)
isEpoch()
-102390933
-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()
'2019-10-22'
null
# Example (2)
isEpochMillis()
102390933
102390933
# Example (3)
isEpochMillis()
'2001-01-01T01:00:00.000Z'
null
# Example (4)
isEpochMillis({ allowBefore1970: false })
-102390933
null
# Example (5)
isEpochMillis()
-102390933
-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()
'2021-05-14T10:00:00.000Z'
'2021-05-14T10:00:00.000Z'
# Example (2)
isFriday()
[ 1620986400000, -620 ]
'2021-05-14T10:00:00.000-10:20'
# Example (3)
isFriday()
'2021-05-09T10:00:00.000Z'
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()
'2021-05-10T10:00:00.000Z'
null
# Example (2)
isFuture()
'2121-05-09T10:00:00.000Z'
'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()
102390933
null
# Example (2)
isISO8601()
'2001-01-01T01:00:00.000Z'
'2001-01-01T01:00:00.000Z'
# Example (3)
isISO8601()
102390933
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()
'2020-05-10T10:00:00.000Z'
'2020-05-10T10:00:00.000Z'
# Example (2)
isLeapYear()
[ 1589104800000, 60 ]
'2020-05-10T10:00:00.000+01:00'
# Example (3)
isLeapYear()
'2021-05-10T10:00:00.000Z'
null
isMonday
Type: FIELD_VALIDATION
Returns the the input if it is on a Monday
Accepts
String
Date
Number
Examples
# Example (1)
isMonday()
'2021-05-10T10:00:00.000Z'
'2021-05-10T10:00:00.000Z'
# Example (2)
isMonday()
'2021-05-09T10:00:00.000Z'
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()
'2021-05-10T10:00:00.000Z'
'2021-05-10T10:00:00.000Z'
# Example (2)
isPast()
'2121-05-09T10:00:00.000Z'
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()
'2021-05-08T10:00:00.000Z'
'2021-05-08T10:00:00.000Z'
# Example (2)
isSaturday()
'2021-05-09T10:00:00.000Z'
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()
'2021-05-09T10:00:00.000Z'
'2021-05-09T10:00:00.000Z'
# Example (2)
isSunday()
1620554400000
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()
'2021-05-13T10:00:00.000Z'
'2021-05-13T10:00:00.000Z'
# Example (2)
isThursday()
'2021-05-09T10:00:00.000Z'
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()
'2021-10-28T22:06:00.484Z'
'2021-10-28T22:06:00.484Z'
# Example (2)
isToday()
'2020-05-09T10:00:00.000Z'
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()
'2021-10-28T22:06:00.485Z'
null
Represents day after current time
# Example (2)
isTomorrow()
'2021-10-29T22:06:00.485Z'
'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()
'2021-05-11T10:00:00.000Z'
'2021-05-11T10:00:00.000Z'
# Example (2)
isTuesday()
'2021-05-09T10:00:00.000Z'
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()
'2021-05-12T10:00:00.000Z'
'2021-05-12T10:00:00.000Z'
# Example (2)
isWednesday()
'2021-05-09T10:00:00.000Z'
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()
'2021-05-12T10:00:00.000Z'
'2021-05-12T10:00:00.000Z'
# Example (2)
isWeekday()
'2021-05-13T10:00:00.000Z'
'2021-05-13T10:00:00.000Z'
# Example (3)
isWeekday()
'2021-05-09T10:00:00.000Z'
null
# Example (4)
isWeekday()
'2021-05-08T10:00:00.000Z'
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()
'2021-05-12T10:00:00.000Z'
null
# Example (2)
isWeekend()
'2021-05-13T10:00:00.000Z'
null
# Example (3)
isWeekend()
'2021-05-09T10:00:00.000Z'
'2021-05-09T10:00:00.000Z'
# Example (4)
isWeekend()
'2021-05-08T10:00:00.000Z'
'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()
'2021-10-28T22:06:00.488Z'
null
Represents day before current time
# Example (2)
isYesterday()
'2021-10-27T22:06:00.488Z'
'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()
-1
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()
-1
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()
1
0
Since this function doesn't work with numbers <=0, null will be returned
# Example (2)
acosh()
0
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 })
10
11
# Example (2)
add({ value: 5 })
10
15
# Example (3)
add({ value: -5 })
10
5
# Example (4)
add({ value: 12 })
12
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()
[ 100, 10 ]
110
# Example (2)
addValues()
[ 10 ]
10
# Example (3)
addValues()
[ 10, 100000, 2 ]
100012
# Example (4)
addValues()
[ [ 10, null ], 100000, [ 2 ], null ]
100012
# Example (5)
addValues()
2
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()
1
1.5707963267948966
asinh
Type: FIELD_TRANSFORM
Returns the hyperbolic arcsine of the given number
Accepts
Number
Examples
# Example (1)
asinh()
1
0.881373587019543
atan
Type: FIELD_TRANSFORM
Returns the arctangent (in radians) of the given number
Accepts
Number
Examples
# Example (1)
atan()
1
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()
[ 15, 90 ]
1.4056476493802699
# Example (2)
atan2()
[ 90, 15 ]
0.16514867741462683
# Example (3)
atan2()
[ -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()
0.5
0.5493061443340548
Typically this would return -Infinity but that cannot be stored or serialized so null is returned
# Example (2)
atanh()
-1
null
cbrt
Type: FIELD_TRANSFORM
Returns the cube root of a number
Accepts
Number
Examples
# Example (1)
cbrt()
64
4
# Example (2)
cbrt()
1
1
ceil
Type: FIELD_TRANSFORM
Rounds a number up to the next largest integer
Accepts
Number
Examples
# Example (1)
ceil()
0.95
1
# Example (2)
ceil()
0.1
1
# Example (3)
ceil()
-7.004
-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()
1
31
# Example (2)
clz32()
1000
22
# Example (3)
clz32()
4
29
cos
Type: FIELD_TRANSFORM
Returns the cosine of the specified angle, which must be specified in radians
Accepts
Number
Examples
# Example (1)
cos()
0
1
# Example (2)
cos()
3.141592653589793
-1
# Example (3)
cos()
6.283185307179586
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()
0
1
# Example (2)
cosh()
3.141592653589793
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 })
10
2
# Example (2)
divide({ value: 1 })
10
10
# Example (3)
divide({ value: 2 })
10
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()
[ 100, 10 ]
10
# Example (2)
divideValues()
[ 10 ]
10
# Example (3)
divideValues()
[ 10, 100000, 2 ]
0.00005
# Example (4)
divideValues()
[ [ 10, null ], 100000, [ 2 ], null ]
0.00005
# Example (5)
divideValues()
2
2
# Example (6)
divideValues()
[ 0, 0 ]
NaN
# Example (7)
divideValues()
[ 100, 0 ]
Infinity
exp
Type: FIELD_TRANSFORM
Returns a number representing
e^x
, wheree
is Euler's number andx
is the argument
Accepts
Number
Examples
# Example (1)
exp()
0
1
# Example (2)
exp()
1
2.718281828459045
expm1
Type: FIELD_TRANSFORM
Returns a number representing
e^x - 1
, wheree
is Euler's number andx
is the argument
Accepts
Number
Examples
# Example (1)
expm1()
0
0
# Example (2)
expm1()
1
1.718281828459045
floor
Type: FIELD_TRANSFORM
Rounds a number down to the previous largest integer
Accepts
Number
Examples
# Example (1)
floor()
0.95
0
# Example (2)
floor()
0.1
0
# Example (3)
floor()
-7.004
-8
fround
Type: FIELD_TRANSFORM
Returns the nearest 32-bit single precision float representation of the given number
Accepts
Number
Examples
# Example (1)
fround()
5.5
5.5
# Example (2)
fround()
-5.05
-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()
[ 3, 4 ]
5
# Example (2)
hypot()
[ 5, 12 ]
13
# Example (3)
hypot()
[ 3, 4, null, 5 ]
7.0710678118654755
# Example (4)
hypot()
null
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()
1
0
# Example (2)
log()
10
2.302585092994046
# Example (3)
log()
-1
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()
1
0.6931471805599453
# Example (2)
log1p()
0
0
Typically this would return -Infinity but that cannot be stored or serialized so null is returned
# Example (3)
log1p()
-1
null
Typically this would return NaN but that cannot be stored or serialized so null is returned
# Example (4)
log1p()
-2
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()
2
1
Typically this would return -Infinity but that cannot be stored or serialized so null is returned
# Example (2)
log2()
0
null
# Example (3)
log2()
-2
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()
10
1
Typically this would return -Infinity but that cannot be stored or serialized so null is returned
# Example (2)
log10()
0
null
# Example (3)
log10()
-2
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()
[ 100, 10 ]
100
# Example (2)
maxValues()
[ 10 ]
10
# Example (3)
maxValues()
[ 10, 100000, 2 ]
100000
# Example (4)
maxValues()
[ [ 10, null ], 100000, [ 2 ], null ]
100000
# Example (5)
maxValues()
2
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()
[ 100, 10 ]
10
# Example (2)
minValues()
[ 10 ]
10
# Example (3)
minValues()
[ 10, 100000, 2 ]
2
# Example (4)
minValues()
[ [ 10, null ], 100000, [ 2 ], null ]
2
# Example (5)
minValues()
2
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 })
10
0
# Example (2)
modulus({ value: 2 })
9
1
# Example (3)
modulus({ value: -5 })
10
0
# Example (4)
modulus({ value: 10 })
101
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 })
10
50
# Example (2)
multiply({ value: -2 })
10
-20
# Example (3)
multiply({ value: 2 })
10
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()
[ 100, 10 ]
1000
# Example (2)
multiplyValues()
[ 10 ]
10
# Example (3)
multiplyValues()
[ 10, 100000, 2 ]
2000000
# Example (4)
multiplyValues()
[ [ 10, null ], 100000, [ 2 ], null ]
2000000
# Example (5)
multiplyValues()
2
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 })
7
343
# Example (2)
pow({ value: 0.5 })
4
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 })
1
1
round
Type: FIELD_TRANSFORM
Returns the value of a number rounded to the nearest integer
Accepts
Number
Examples
# Example (1)
round()
0.95
1
# Example (2)
round()
0.1
0
# Example (3)
round()
-7.004
-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 })
'10.123444'
10.1
# Example (2)
setPrecision({ digits: 1, truncate: true })
10.253444
10.2
# Example (3)
setPrecision({ digits: 1, truncate: false })
10.253444
10.3
# Example (4)
setPrecision({ digits: 2 })
3.141592653589793
3.14
# Example (5)
setPrecision({ digits: 0 })
3.141592653589793
3
# Example (6)
setPrecision({ digits: -1 })
23.4
Throws:
Expected digits to be between 0-100
# Example (7)
setPrecision({ digits: 1000 })
23.4
Throws:
Expected digits to be between 0-100
# Example (8)
setPrecision({ digits: 2, truncate: true })
{ lat: 32.12399971230023, lon: -20.95522300035 }
{ lat: 32.12, lon: -20.95 }
# Example (9)
setPrecision({ digits: 2, truncate: true })
{ lat: 32.12399971230023, lon: -20.95522300035 }
{ lat: 32.12, lon: -20.95 }
# Example (10)
setPrecision({ digits: 2 })
NaN
NaN
# Example (11)
setPrecision({ digits: 2 })
Infinity
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()
3
1
# Example (2)
sign()
-3
-1
# Example (3)
sign()
0
0
sin
Type: FIELD_TRANSFORM
Returns the sine of the input value
Accepts
Number
Examples
# Example (1)
sin()
0
0
# Example (2)
sin()
1
0.8414709848078965
# Example (3)
sin()
1.5707963267948966
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()
0
0
# Example (2)
sinh()
1
1.1752011936438014
# Example (3)
sinh()
-1
-1.1752011936438014
sqrt
Type: FIELD_TRANSFORM
Returns the square root of the input
Accepts
Number
Examples
# Example (1)
sqrt()
9
3
# Example (2)
sqrt()
2
1.4142135623730951
# Example (3)
sqrt()
-1
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 })
10
9
# Example (2)
subtract({ value: 5 })
10
5
# Example (3)
subtract({ value: -5 })
10
15
# Example (4)
subtract({ value: 2 })
10
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()
[ 100, 10 ]
90
# Example (2)
subtractValues()
[ 10 ]
10
# Example (3)
subtractValues()
[ 10, 100000, 2 ]
-99992
# Example (4)
subtractValues()
[ [ 10, null ], 100000, [ 2 ], null ]
-99992
# Example (5)
subtractValues()
2
2
tan
Type: FIELD_TRANSFORM
Returns the tangent of a number
Accepts
Number
Examples
# Example (1)
tan()
1
1.5574077246549023
tanh
Type: FIELD_TRANSFORM
Returns the hyperbolic tangent of a number
Accepts
Number
Examples
# Example (1)
tanh()
-1
-0.7615941559557649
# Example (2)
tanh()
0
0
toCelsius
Type: FIELD_TRANSFORM
Returns the equivalent celsius value from the fahrenheit input
Accepts
Number
Examples
# Example (1)
toCelsius()
32
0
# Example (2)
toCelsius()
69.8
21
toFahrenheit
Type: FIELD_TRANSFORM
Returns the equivalent fahrenheit value from the celsius input
Accepts
Number
Examples
# Example (1)
toFahrenheit()
0
32
# Example (2)
toFahrenheit()
22
71.6
toNumber
Type: FIELD_TRANSFORM
Converts an entity to a number, can handle IPs and Dates
Examples
# Example (1)
toNumber()
'9007199254740991'
9007199254740991
# Example (2)
toNumber()
'22'
22
# Example (3)
toNumber()
'22'
22
# Example (4)
toNumber()
'10.16.32.210'
168829138
# Example (5)
toNumber()
'2001:2::'
'42540488320432167789079031612388147199'
# Example (6)
toNumber()
'2001-01-01T01:00:00.000Z'
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 })
10
null
# Example (2)
inNumberRange({ min: 100 })
100
null
# Example (3)
inNumberRange({ min: 100, inclusive: true })
100
100
# Example (4)
inNumberRange({ min: 0, max: 100 })
10
10
# Example (5)
inNumberRange({ min: 100, inclusive: true })
Infinity
Infinity
# Example (6)
inNumberRange({ min: 100, inclusive: true })
-Infinity
null
isEven
Type: FIELD_VALIDATION
Returns the input if it is an even number
Accepts
Number
Examples
# Example (1)
isEven()
100
100
# Example (2)
isEven()
99
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 })
10
null
# Example (2)
isGreaterThan({ value: 50 })
50
null
# Example (3)
isGreaterThan({ value: 110 })
120
120
# Example (4)
isGreaterThan({ value: 150 })
151
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 })
10
null
# Example (2)
isGreaterThanOrEqualTo({ value: 50 })
50
50
# Example (3)
isGreaterThanOrEqualTo({ value: 110 })
120
120
# Example (4)
isGreaterThanOrEqualTo({ value: 150 })
151
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 })
110
null
# Example (2)
isLessThan({ value: 50 })
50
null
# Example (3)
isLessThan({ value: 110 })
100
100
# Example (4)
isLessThan({ value: 150 })
149
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 })
110
null
# Example (2)
isLessThanOrEqualTo({ value: 50 })
50
50
# Example (3)
isLessThanOrEqualTo({ value: 110 })
100
100
# Example (4)
isLessThanOrEqualTo({ value: 150 })
149
149
isOdd
Type: FIELD_VALIDATION
Returns the input if it is an odd number
Accepts
Number
Examples
# Example (1)
isOdd()
100
null
# Example (2)
isOdd()
99
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' })
'thisisastring'
'thisisastring'
# Example (2)
equals({ value: 'thisisastring' })
1234
null
# Example (3)
equals({ value: [ 'an', 'array', 'of', 'values' ] })
[ 'an', 'array', 'of', 'values' ]
[ 'an', 'array', 'of', 'values' ]
# Example (4)
equals({ value: { foo: 'bar', deep: { value: 'kitty' } } })
{ foo: 'bar', deep: { value: 'kitty' } }
{ foo: 'bar', deep: { value: 'kitty' } }
# Example (5)
equals({ value: { foo: 'bar', deep: { value: 'kitty' } } })
{ foo: 'bar', deep: { value: 'other stuff' } }
null
# Example (6)
equals({ value: true })
false
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()
'85031b6f407e7f25cf826193338f7a4c2dc8c8b5130f5ca2c69a66d9f5107e33'
null
# Example (2)
isEmpty()
''
''
# Example (3)
isEmpty()
[]
[]
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' } })
'key1'
'value1'
# Example (2)
lookup({ in: { '123': 4567, '8910': 1112 } })
8910
1112
# Example (3)
lookup({ in: { key1: 'value1', key2: 'value2' } })
'key3'
undefined
# Example (4)
lookup({
in: '\n' +
' 1:foo\n' +
' 2:bar\n' +
' 3:max\n' +
' '
})
2
'bar'
# Example (5)
lookup({ in: [ 'foo', 'bar', 'max' ] })
2
'max'
# Example (6)
lookup({ in: [ 'foo', 'bar', 'max' ] })
2
'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' })
'example'
'example'
# Example (2)
contains({ value: 'example' })
'example'
'example'
# Example (3)
contains({ value: 'test' })
'example'
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' })
'apple'
'apple'
# Example (2)
endsWith({ value: 'a' })
'orange'
null
# Example (3)
endsWith({ value: 'so' })
'some word'
null
# Example (4)
endsWith({ value: 'word' })
'other word'
'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()
'example123456'
null
# Example (2)
isAlpha({ locale: 'pl-Pl' })
'ThisiZĄĆĘŚŁ'
'ThisiZĄĆĘŚŁ'
# Example (3)
isAlpha()
'not_alpha.com'
null
# Example (4)
isAlpha()
true
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()
'example123456'
'example123456'
# Example (2)
isAlphaNumeric({ locale: 'pl-Pl' })
'ThisiZĄĆĘŚŁ1234'
'ThisiZĄĆĘŚŁ1234'
# Example (3)
isAlphaNumeric()
'not_alphanumeric.com'
null
# Example (4)
isAlphaNumeric()
true
null
isBase64
Type: FIELD_VALIDATION
Returns the input if it is a valid base64 string, otherwise returns null
Accepts
String
Examples
# Example (1)
isBase64()
'ZnJpZW5kbHlOYW1lNw=='
'ZnJpZW5kbHlOYW1lNw=='
# Example (2)
isBase64()
'manufacturerUrl7'
null
# Example (3)
isBase64()
1234123
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()
'US'
'US'
# Example (2)
isCountryCode()
'ZM'
'ZM'
# Example (3)
isCountryCode()
'GB'
'GB'
# Example (4)
isCountryCode()
'UK'
null
# Example (5)
isCountryCode()
12345
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()
'string@gmail.com'
'string@gmail.com'
# Example (2)
isEmail()
'non.us.email@thing.com.uk'
'non.us.email@thing.com.uk'
# Example (3)
isEmail()
'Abc@def@example.com'
'Abc@def@example.com'
# Example (4)
isEmail()
'cal+henderson@iamcalx.com'
'cal+henderson@iamcalx.com'
# Example (5)
isEmail()
'customer/department=shipping@example.com'
'customer/department=shipping@example.com'
# Example (6)
isEmail()
'user@blah.com/junk.junk?a=<tag value="junk"'
null
# Example (7)
isEmail()
'Abc@def @ example.com'
null
# Example (8)
isEmail()
'bad email address'
null
# Example (9)
isEmail()
12345
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()
'example.com'
'example.com'
# Example (2)
isFQDN()
'international-example.com.br'
'international-example.com.br'
# Example (3)
isFQDN()
'1234.com'
'1234.com'
# Example (4)
isFQDN()
'no_underscores.com'
null
# Example (5)
isFQDN()
'**.bad.domain.com'
null
# Example (6)
isFQDN()
'example.0'
null
# Example (7)
isFQDN()
12345
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' })
'85031b6f407e7f25cf826193338f7a4c2dc8c8b5130f5ca2c69a66d9f5107e33'
'85031b6f407e7f25cf826193338f7a4c2dc8c8b5130f5ca2c69a66d9f5107e33'
# Example (2)
isHash({ algo: 'md5' })
'85031b6f407e7f25cf826193338f7a4c2dc8c8b5130f5ca2c69a66d9f5107e33'
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()
'46707123456'
'46707123456'
# Example (2)
isISDN()
'1-808-915-6800'
'1-808-915-6800'
# Example (3)
isISDN({ country: 'US' })
'8089156800'
'8089156800'
# Example (4)
isISDN()
'8089156800'
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 })
'iam8char'
'iam8char'
# Example (2)
isLength({ size: 8 })
'iamnot8char'
null
# Example (3)
isLength({ min: 3 })
'aString'
'aString'
# Example (4)
isLength({ min: 3, max: 5 })
'aString'
null
# Example (5)
isLength({ min: 3, max: 5 })
4
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()
'00:1f:f3:5b:2b:1f'
'00:1f:f3:5b:2b:1f'
# Example (2)
isMACAddress()
'001ff35b2b1f'
'001ff35b2b1f'
# Example (3)
isMACAddress()
'00-1f-f3-5b-2b-1f'
'00-1f-f3-5b-2b-1f'
# Example (4)
isMACAddress({ delimiter: 'colon' })
'00-1f-f3-5b-2b-1f'
null
# Example (5)
isMACAddress({ delimiter: 'any' })
'00-1f-f3-5b-2b-1f'
'00-1f-f3-5b-2b-1f'
# Example (6)
isMACAddress({ delimiter: 'dash' })
'00-1f-f3-5b-2b-1f'
'00-1f-f3-5b-2b-1f'
# Example (7)
isMACAddress({ delimiter: 'dot' })
'001f.f35b.2b1f'
'001f.f35b.2b1f'
# Example (8)
isMACAddress({ delimiter: 'none' })
'001ff35b2b1f'
'001ff35b2b1f'
# Example (9)
isMACAddress()
'aString'
null
# Example (10)
isMACAddress()
4
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()
'application/javascript'
'application/javascript'
# Example (2)
isMIMEType()
'text/html'
'text/html'
# Example (3)
isMIMEType()
'application'
null
# Example (4)
isMIMEType()
''
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()
'46707123456'
'46707123456'
# Example (2)
isPhoneNumberLike()
'1-808-915-6800'
'1-808-915-6800'
# Example (3)
isPhoneNumberLike()
'79525554602'
'79525554602'
# Example (4)
isPhoneNumberLike()
'223457823432432423324'
null
# Example (5)
isPhoneNumberLike()
'2234'
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()
'49151'
'49151'
# Example (2)
isPort()
'80'
'80'
# Example (3)
isPort()
'65536'
null
# Example (4)
isPort()
'not a port'
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()
'85249'
'85249'
# Example (2)
isPostalCode({ locale: 'RU' })
'191123'
'191123'
# Example (3)
isPostalCode()
'bobsyouruncle'
null
# Example (4)
isPostalCode({ locale: 'CN' })
'this is not a postal code'
null
isString
Type: FIELD_VALIDATION
Returns the input if it is is a string, otherwise returns null
Accepts
String
Examples
# Example (1)
isString()
'this is a string'
'this is a string'
# Example (2)
isString()
'12345'
'12345'
# Example (3)
isString()
{ hello: 'i am an object' }
null
# Example (4)
isString()
1234
null
# Example (5)
isString()
[ '12345', 'some more stuff' ]
[ '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()
'http://someurl.com.uk'
'http://someurl.com.uk'
# Example (2)
isURL()
'ftp://someurl.bom:8080?some=bar&hi=bob'
'ftp://someurl.bom:8080?some=bar&hi=bob'
# Example (3)
isURL()
'http://xn--fsqu00a.xn--3lr804guic'
'http://xn--fsqu00a.xn--3lr804guic'
# Example (4)
isURL()
'http://example.com/hello%20world'
'http://example.com/hello%20world'
# Example (5)
isURL()
'bob.com'
'bob.com'
# Example (6)
isURL()
'isthis_valid_uri.com'
null
# Example (7)
isURL()
'http://sthis valid uri.com'
null
# Example (8)
isURL()
'hello://validuri.com'
null
isUUID
Type: FIELD_VALIDATION
Returns the input if it is a valid UUID, otherwise returns null
Accepts
String
Examples
# Example (1)
isUUID()
'95ecc380-afe9-11e4-9b6c-751b66dd541e'
'95ecc380-afe9-11e4-9b6c-751b66dd541e'
# Example (2)
isUUID()
'123e4567-e89b-82d3-f456-426655440000'
'123e4567-e89b-82d3-f456-426655440000'
# Example (3)
isUUID()
'95ecc380:afe9:11e4:9b6c:751b66dd541e'
null
# Example (4)
isUUID()
'123e4567-e89b-x2d3-0456-426655440000'
null
# Example (5)
isUUID()
'randomstring'
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' })
'apple'
'apple'
# Example (2)
startsWith({ value: 'a' })
'orange'
null
# Example (3)
startsWith({ value: 'so' })
'some word'
'some word'
# Example (4)
startsWith({ value: 'so' })
'other word'
null
# Example (5)
startsWith({ value: 't' })
'hat'
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()
'foo'
'acbd18db4cc2f85cedef654fccc4a4d8'
# Example (2)
createID()
[ 'foo1', 'bar1' ]
'ad3ffa6c042cdee09c226a0544215f6f'
# Example (3)
createID({ hash: 'sha256' })
[ 'foo1', 'bar1' ]
'62910cf6a9d2b270a7f51cc7fc30efe274c0cdf2c04f18ac0757843b1c4dade2'
decodeBase64
Type: FIELD_TRANSFORM
Returns the base64-decoded version of the input string
Accepts
String
Examples
# Example (1)
decodeBase64()
'c29tZSBzdHJpbmc='
'some string'
decodeHex
Type: FIELD_TRANSFORM
Returns the hexadecimal-decoded version of the input string
Accepts
String
Examples
# Example (1)
decodeHex()
'736f6d652076616c756520666f722068657820656e636f64696e67'
'some value for hex encoding'
decodeURL
Type: FIELD_TRANSFORM
Returns the url-decoded version of the input string
Accepts
String
Examples
# Example (1)
decodeURL()
'google.com%3Fq%3DHELLO%20AND%20GOODBYE'
'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' })
'{ "some": "data" }'
'e43e698b8ee20f09ae4257e81d7c8ac5074cdda2a8aef8d6c00dbbe5b404f7e5'
# Example (2)
encode({ algo: 'md5' })
'{ "some": "data" }'
'7e33b72a611da99c7e9013dd44dbbdad'
# Example (3)
encode({ algo: 'url' })
'google.com?q=HELLO AND GOODBYE'
'google.com%3Fq%3DHELLO%20AND%20GOODBYE'
# Example (4)
encode({ algo: 'base64' })
'HELLO AND GOODBYE'
'SEVMTE8gQU5EIEdPT0RCWUU='
# Example (5)
encode({ algo: 'sha1', digest: 'base64' })
'{ "some": "data" }'
'6MsUBHluumd5onY3fM6ZpQKjZIE='
encodeBase64
Type: FIELD_TRANSFORM
Returns a base64 hashed version of the input string
Accepts
String
Examples
# Example (1)
encodeBase64()
'some string'
'c29tZSBzdHJpbmc='
encodeHex
Type: FIELD_TRANSFORM
Returns a hexadecimal hashed version of the input string
Accepts
String
Examples
# Example (1)
encodeHex()
'some value for hex encoding'
'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()
'{ "some": "data" }'
'e43e698b8ee20f09ae4257e81d7c8ac5074cdda2a8aef8d6c00dbbe5b404f7e5'
# Example (2)
encodeSHA({ digest: 'base64' })
'{ "some": "data" }'
'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()
'{ "some": "data" }'
'e8cb1404796eba6779a276377cce99a502a36481'
# Example (2)
encodeSHA1({ digest: 'base64' })
'{ "some": "data" }'
'6MsUBHluumd5onY3fM6ZpQKjZIE='
encodeURL
Type: FIELD_TRANSFORM
Returns a URL encoded version of the input value
Accepts
String
Examples
# Example (1)
encodeURL()
'google.com?q=HELLO AND GOODBYE'
'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()
'0123456789abcdef'
4
# Example (2)
entropy({ algo: 'shannon' })
'1223334444'
1.8464393446710154
# Example (3)
entropy({ algo: 'unknownAlgoName' })
'1223334444'
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: '>' })
'<hello>'
'hello'
# Example (2)
extract({ regex: 'he.*' })
'hello'
'hello'
# Example (3)
extract({ regex: '/([A-Z]\\w+)/', global: true })
'Hello World some other things'
[ 'Hello', 'World' ]
# Example (4)
extract({ start: '<', end: '>', global: true })
'<hello> some stuff <world>'
[ '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()
[
'a', ' ', 's',
't', 'r', 'i',
'n', 'g'
]
'a string'
# Example (2)
join({ delimiter: ',' })
[ 'a string', 'found' ]
'a string,found'
# Example (3)
join({ delimiter: ' - ' })
[ 'a', 'stri', 'ng' ]
'a - stri - ng'
# Example (4)
join({ delimiter: ' ' })
'a string'
'a string'
# Example (5)
join({ delimiter: ':' })
[ 'foo', 1, true ]
'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' })
'Hi bob'
'Hi mel'
Does not replace as it is not an exact match
# Example (2)
replaceLiteral({ search: 'bob', replace: 'mel' })
'Hi Bob'
'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' })
'somestring'
'domestring'
# Example (2)
replaceRegex({ regex: 's|e', replace: 'd', global: true })
'somestring'
'domddtring'
# Example (3)
replaceRegex({ regex: 'm|t', replace: 'W', global: true, ignoreCase: true })
'soMesTring'
'soWesWring'
# Example (4)
replaceRegex({ regex: '\\*', replace: '', global: true })
'a***a***a'
'aaa'
reverse
Type: FIELD_TRANSFORM
Returns the input string with its characters in reverse order
Accepts
String
Examples
# Example (1)
reverse()
'hello'
'olleh'
# Example (2)
reverse()
'more words'
'sdrow erom'
# Example (3)
reverse()
[ 'hello', 'more' ]
[ '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()
'astring'
[
'a', 's', 't',
'r', 'i', 'n',
'g'
]
Delimiter is not found so the whole input is returned
# Example (2)
split({ delimiter: ',' })
'astring'
[ 'astring' ]
# Example (3)
split({ delimiter: '-' })
'a-stri-ng'
[ 'a', 'stri', 'ng' ]
# Example (4)
split({ delimiter: ' ' })
'a string'
[ '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()
'HELLO there'
'helloThere'
# Example (2)
toCamelCase()
'billy'
'billy'
# Example (3)
toCamelCase()
'Hey There'
'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()
'+33-1-22-33-44-55'
'33122334455'
# Example (2)
toISDN()
'1(800)FloWErs'
'18003569377'
# Example (3)
toISDN()
4917600000000
'4917600000000'
# Example (4)
toISDN()
49187484
'49187484'
# Example (5)
toISDN()
'something'
toKebabCase
Type: FIELD_TRANSFORM
Converts one or more words into a single word joined by dashes
Accepts
String
Examples
# Example (1)
toKebabCase()
'HELLO there'
'hello-there'
# Example (2)
toKebabCase()
'billy'
'billy'
# Example (3)
toKebabCase()
'Hey There'
'hey-there'
toLowerCase
Type: FIELD_TRANSFORM
Converts a string to lower case characters
Accepts
String
Examples
# Example (1)
toLowerCase()
'HELLO there'
'hello there'
# Example (2)
toLowerCase()
'biLLy'
'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()
'HELLO there'
'HelloThere'
# Example (2)
toPascalCase()
'billy'
'Billy'
# Example (3)
toPascalCase()
'Hey There'
'HeyThere'
toSnakeCase
Type: FIELD_TRANSFORM
Converts one or more words into a single word joined by underscores
Accepts
String
Examples
# Example (1)
toSnakeCase()
'HELLO there'
'hello_there'
# Example (2)
toSnakeCase()
'billy'
'billy'
# Example (3)
toSnakeCase()
'Hey There'
'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()
true
'true'
# Example (2)
toString()
{ hello: 'world' }
'{"hello":"world"}'
# Example (3)
toString()
278218429446951548637196401n
'278218429446951548637196400'
# Example (4)
toString()
[ true, false ]
[ '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()
'HELLO there'
'HELLO There'
# Example (2)
toTitleCase()
'billy'
'Billy'
# Example (3)
toTitleCase()
'Hey There'
'Hey There'
toUpperCase
Type: FIELD_TRANSFORM
Converts a string to upper case characters
Accepts
String
Examples
# Example (1)
toUpperCase()
'hello'
'HELLO'
# Example (2)
toUpperCase()
'billy'
'BILLY'
# Example (3)
toUpperCase()
'Hey There'
'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()
' other_things '
'other_things'
# Example (2)
trim()
'Stuff '
'Stuff'
# Example (3)
trim()
' hello'
'hello'
# Example (4)
trim()
' '
''
# Example (5)
trim()
'Spider Man'
'Spider Man'
# Example (6)
trim({ chars: 'a' })
'aaaaSpider Manaaaa'
'Spider Man'
Any new char, including whitespace will stop the trim, it must be consecutive
# Example (7)
trim({ chars: 'a' })
'aa aaSpider Manaa aa'
' aaSpider Manaa '
# Example (8)
trim({ chars: 'fast' })
'fast cars race fast'
' cars race '
# Example (9)
trim({ chars: 'fatc ' })
'fast example cata'
'st example'
# Example (10)
trim({ chars: '\r' })
'\t\r\rtrim this\r\r'
'\t\r\rtrim this'
# Example (11)
trim({ chars: '.*' })
'.*.*a test.*.*.*.*'
'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()
' left'
' left'
# Example (2)
trimEnd()
'right '
'right'
# Example (3)
trimEnd()
' '
''
# Example (4)
trimEnd({ chars: '*' })
'*****Hello****Bob*****'
'*****Hello****Bob'
# Example (5)
trimEnd({ chars: 'fast' })
'fast cars race fast'
'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()
' Hello Bob '
'Hello Bob '
# Example (2)
trimStart({ chars: '__--' })
'__--__--__some__--__word'
'some__--__word'
# Example (3)
trimStart()
' '
''
# Example (4)
trimStart({ chars: '*' })
'*****Hello****Bob*****'
'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 })
'thisisalongstring'
'this'
# Example (2)
truncate({ size: 8 })
'Hello world'
'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()
'11.0.1.18'
'11.0.1.18'
# Example (2)
isIP()
'2001:db8:85a3:8d3:1319:8a2e:370:7348'
'2001:db8:85a3:8d3:1319:8a2e:370:7348'
# Example (3)
isIP()
'172.394.0.1'
null
# Example (4)
isIP()
1234567
null
# Example (5)
isIP()
'not an IP address'
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' })
'8.8.8.8'
'8.8.8.8'
# Example (2)
inIPRange({ min: 'fd00::123', max: 'fd00::ea00' })
'fd00::b000'
'fd00::b000'
# Example (3)
inIPRange({ min: 'fd00::123' })
'fd00::b000'
'fd00::b000'
# Example (4)
inIPRange({ cidr: '8.8.8.0/24' })
'8.8.10.8'
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()
'1.2.3.4/32'
'1.2.3.4/32'
# Example (2)
isCIDR()
'2001::1234:5678/128'
'2001::1234:5678/128'
# Example (3)
isCIDR()
'8.8.8.10'
null
# Example (4)
isCIDR()
'badIPAddress/24'
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()
'11.0.1.18'
'11.0.1.18'
# Example (2)
isIPv4()
'2001:db8:85a3:8d3:1319:8a2e:370:7348'
null
# Example (3)
isIPv4()
'172.394.0.1'
null
# Example (4)
isIPv4()
'not an IP address'
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()
'2001:db8:85a3:8d3:1319:8a2e:370:7348'
'2001:db8:85a3:8d3:1319:8a2e:370:7348'
# Example (2)
isIPv6()
'fc00:db8::1'
'fc00:db8::1'
# Example (3)
isIPv6()
'::FFFF:12.155.166.101'
'::FFFF:12.155.166.101'
# Example (4)
isIPv6()
'11.0.1.18'
null
# Example (5)
isIPv6()
'not an IP address'
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()
'192.168.0.1'
'192.168.0.1'
# Example (2)
isNonRoutableIP()
'2001:db8::1'
'2001:db8::1'
# Example (3)
isNonRoutableIP()
'172.28.4.1'
'172.28.4.1'
# Example (4)
isNonRoutableIP()
'8.8.8.8'
null
# Example (5)
isNonRoutableIP()
'2001:2ff::ffff'
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()
'8.8.8.8'
'8.8.8.8'
# Example (2)
isRoutableIP()
'2620:4f:123::'
'2620:4f:123::'
# Example (3)
isRoutableIP()
'192.168.255.254'
null
# Example (4)
isRoutableIP()
'2001:4:112::'
null
# Example (5)
isRoutableIP()
'not an IP address'
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()
'::ffff:10.2.1.18'
'::ffff:10.2.1.18'
# Example (2)
isMappedIPv4()
'::122.168.5.18'
'::122.168.5.18'
# Example (3)
isMappedIPv4()
'10.16.32.210'
null
# Example (4)
isMappedIPv4()
'2001:4:112::'
null
# Example (5)
isMappedIPv4()
'not an IP address'
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()
'::FFFF:192.52.193.1'
'192.52.193.1'
# Example (2)
extractMappedIPv4()
'::122.168.5.18'
'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()
'10.16.32.210'
'210.32.16.10'
# Example (2)
reverseIP()
'2001:0db8:0000:0000:0000:8a2e:0370:7334'
'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()
'2001:2::'
'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()
'10.16.32.210'
168829138
# Example (2)
ipToInt()
'2001:2::'
'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 })
168829138
'10.16.32.210'
# Example (2)
intToIP({ version: '6' })
'42540488320432167789079031612388147200'
'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()
'8.8.12.118/24'
'8.8.12.1'
# Example (2)
getCIDRMin()
'2001:0db8:0123:4567:89ab:cdef:1234:5678/128'
'2001:db8:123:4567:89ab:cdef:1234:5678'
# Example (3)
getCIDRMin()
'2001:0db8:0123:4567:89ab:cdef:1234:5678/46'
'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()
'8.8.12.118/24'
'8.8.12.254'
# Example (2)
getCIDRMax()
'2001:0db8:0123:4567:89ab:cdef:1234:5678/128'
'2001:db8:123:4567:89ab:cdef:1234:5678'
# Example (3)
getCIDRMax()
'2001:0db8:0123:4567:89ab:cdef:1234:5678/46'
'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()
'8.8.12.118/24'
'8.8.12.255'
# Example (2)
getCIDRBroadcast()
'1.2.3.4/32'
'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()
'8.8.12.118/24'
'8.8.12.0'
# Example (2)
getCIDRNetwork()
'1.2.3.4/32'
'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 })
'1.2.3.4'
'1.2.3.4/32'
# Example (2)
toCIDR({ suffix: 24 })
'1.2.3.4'
'1.2.3.0/24'
# Example (3)
toCIDR({ suffix: '46' })
'2001:0db8:0123:4567:89ab:cdef:1234:5678'
'2001:db8:120::/46'