Skip to main content

@terascope/data-mate / validations/field-validator

validations/field-validator

Variables

repository

const repository: Repository

Source

data-mate/src/validations/field-validator.ts:18

Functions

contains()

contains(input, _parentContext, args): boolean

Validates the input contains the values specified in args, or that the array of inputs contains the value in args

Parameters

ParameterTypeDescription
inputunknown
_parentContextunknown-
argsobject-
args.valuestring-

Returns

boolean

boolean

Example

FieldValidator.contains('hello', {}, { value: 'hello' }); // true
FieldValidator.contains('hello', {}, { value: 'll' }); // true
FieldValidator.contains(['hello', 'cello'], {}, { value: 'll' }); // true
FieldValidator.contains(['hello', 'stuff'], {}, { value: 'll' }); // false
FieldValidator.contains('12345', {}, { value: '45' }); // true

Source

data-mate/src/validations/field-validator.ts:887


equals()

equals(input, _parentContext, args): boolean

Validates that the input matches the value, of that the input array matches the value provided

Parameters

ParameterTypeDescription
inputunknown
_parentContextunknown-
argsobject-
args.valuestring-

Returns

boolean

boolean

Example

FieldValidator.equals('12345', {}, { value: '12345' }); // true
FieldValidator.equals('hello', {}, { value: 'llo' }); // false
FieldValidator.equals([3, 3], { value: 3 }); // true

Source

data-mate/src/validations/field-validator.ts:914


every()

every(input, _parentContext, __namedParameters): boolean

Validates that the function specified returns true for every single value in the list

Parameters

ParameterTypeDescription
inputunknown
_parentContextunknown-
__namedParametersobject-
__namedParameters.fnstring-
__namedParameters.options?any-

Returns

boolean

boolean

Example

const mixedArray = ['hello', 3, { some: 'obj' }];
const strArray = ['hello', 'world'];

FieldValidator.every([mixedArray, mixedArray { fn: 'isString' }); // false
FieldValidator.every(strArray, strArray, { fn: 'isString' }); // true

Source

data-mate/src/validations/field-validator.ts:1487


exists()

exists(input, _parentContext?): boolean

Will return false if input is null or undefined

Parameters

ParameterTypeDescription
inputunknown
_parentContext?unknown-

Returns

boolean

boolean

Example

FieldValidator.exists({ hello: 'world' }); // true
FieldValidator.exists(null); // false

Source

data-mate/src/validations/field-validator.ts:1426


guard()

guard(input, _parentContext?): boolean

Will throw if input is null or undefined

Parameters

ParameterTypeDescription
inputunknown
_parentContext?unknown-

Returns

boolean

boolean

Example

FieldValidator.guard({ hello: 'world' }); // true
FieldValidator.guard(); // WILL THROW

Source

data-mate/src/validations/field-validator.ts:1409


inIPRange()

inIPRange(input, _parentContext, args): boolean

Validates if the input is within a given range of IP's

Parameters

ParameterTypeDescription
inputunknown
_parentContextunknown-
argsobject
args.cidr?string-
args.max?string-
args.min?string-

Returns

boolean

boolean

Example

FieldValidator.inIPRange('8.8.8.8', {}, { cidr: '8.8.8.0/24' }); // true
FieldValidator.inIPRange('fd00::b000', {}, { min: 'fd00::123', max: 'fd00::ea00' }); // true;
FieldValidator.inIPRange('8.8.8.8', {}, { cidr: '8.8.8.10/32' }); // false

const config = { min: '8.8.8.0', max: '8.8.8.64' };
FieldValidator.inIPRange(['8.8.8.64', '8.8.8.8'], {}, config); // true

Source

data-mate/src/validations/field-validator.ts:622


inNumberRange()

inNumberRange(input, _parentContext, args): boolean

Will return true if number is between args provided, or that the list of numbers are between the values

Parameters

ParameterTypeDescription
inputunknown
_parentContextunknown-
argsobject
args.inclusive?boolean-
args.max?number-
args.min?number-

Returns

boolean

boolean

Example

FieldValidator.inNumberRange(42, {}, { min: 0, max: 100}); // true
FieldValidator.inNumberRange([42, 11, 94], {}, { min: 0, max: 100}); // true
FieldValidator.inNumberRange([42, 11367, 94], {}, { min: 0, max: 100}); // false
FieldValidator.inNumberRange(-42, {}, { min:0 , max: 100 }); // false
FieldValidator.inNumberRange(42, {}, { min: 0, max: 42 }); // false without the inclusive option
FieldValidator.inNumberRange(42, {}, { min: 0, max: 42, inclusive: true }) // true with inclusive

Source

data-mate/src/validations/field-validator.ts:742


isASCII()

isASCII(input, _parentContext?): boolean

Validates that the input is ascii chars or a list of ascii chars

Parameters

ParameterTypeDescription
inputunknown
_parentContext?unknown-

Returns

boolean

boolean

Example

FieldValidator.isASCII('ascii\s__'); // true;
FieldValidator.isASCII('˜∆˙©∂ß'); // false
FieldValidator.isASCII(['some', 'words']); // true;

Source

data-mate/src/validations/field-validator.ts:1000


isAlpha()

isAlpha(input, _parentContext?, args?): boolean

Validates that the input is alpha or a list of alpha values

Parameters

ParameterTypeDescription
inputunknown
_parentContext?unknown-
args?object
args.locale?AlphaLocale-

Returns

boolean

boolean

Example

FieldValidator.isAlpha('ThiSisAsTRing'); // true
FieldValidator.isAlpha('ThisiZĄĆĘŚŁ', {}, { locale: 'pl-Pl' }); // true
FieldValidator.isAlpha('1123_not-valid'); // false
FieldValidator.isAlpha(['validString', 'more']); // true

Source

data-mate/src/validations/field-validator.ts:940


isAlphanumeric()

isAlphanumeric(input, _parentContext?, args?): boolean

Validates that the input is alphanumeric or a list of alphanumeric values

Parameters

ParameterTypeDescription
inputunknown
_parentContext?unknown-
args?object
args.locale?AlphanumericLocale-

Returns

boolean

boolean

Example

FieldValidator.isAlphanumeric('123validString'); // true
FieldValidator.isAlphanumeric('فڤقکگ1234', { locale: 'ku-IQ' }); // true
FieldValidator.isAlphanumeric('-- not valid'); // false
FieldValidator.isAlphanumeric(['134', 'hello']); // true

Source

data-mate/src/validations/field-validator.ts:970


isArray()

isArray(input, _parentContext?): input is any[]

Validates that the input is an array

Parameters

ParameterTypeDescription
inputunknown
_parentContext?unknown-

Returns

input is any[]

boolean

Example

FieldValidator.isArray(undefined); // false
FieldValidator.isArray([1, 2, 3]); // true
FieldValidator.isArray([]); // true

Source

data-mate/src/validations/field-validator.ts:1441


isBase64()

isBase64(input, _parentContext?): boolean

Validates that the input is a base64 encoded string or a list of base64 encoded strings of string or binary data

Parameters

ParameterTypeDescription
inputunknown
_parentContext?unknown-

Returns

boolean

boolean

Example

FieldValidator.isBase64('H4sIADYPj2YAAytJLS4x4gIA2GR0VwYAAAA='); // true
FieldValidator.isBase64('not base 64'); // false\
FieldValidator.isBase64(['H4sIADYPj2YAAytJLS4x4gIA2GR0VwYAAAA=',
'H4sIAFIPj2YAAytJLS4x5AIAGzdZfAYAAAA=']); // true

Source

data-mate/src/validations/field-validator.ts:1025


isBoolean()

isBoolean(input, _parentContext?): boolean

Checks to see if input is a boolean. If given an array, will check if all values are booleans

Parameters

ParameterTypeDescription
inputunknown
_parentContext?unknown-

Returns

boolean

boolean

Example

FieldValidator.isBoolean(false); // true
FieldValidator.isBoolean('astring'); // false
FieldValidator.isBoolean(0); // false
FieldValidator.isBoolean([true, undefined]); // true
FieldValidator.isBoolean(['true', undefined]; // false

Source

data-mate/src/validations/field-validator.ts:197


isBooleanLike()

isBooleanLike(input, _parentContext?): boolean

Checks to see if input is a boolean-like value. If an given an array, it will check to see if all values in the array are boolean-like, does NOT ignore null/undefined values

Parameters

ParameterTypeDescription
inputunknown
_parentContext?unknown-

Returns

boolean

boolean

Example

FieldValidator.isBooleanLike(); // true
FieldValidator.isBooleanLike(null); // true
FieldValidator.isBooleanLike(0); // true
FieldValidator.isBooleanLike('0'); // true
FieldValidator.isBooleanLike('false'); // true
FieldValidator.isBooleanLike('no'); // true
FieldValidator.isBooleanLike(['no', '0', null]); // true

Source

data-mate/src/validations/field-validator.ts:221


isCIDR()

isCIDR(input, _parentContext?): boolean

Validates that input is a cidr or a list of cidr values

Parameters

ParameterTypeDescription
inputunknown
_parentContext?unknown-

Returns

boolean

boolean

Example

FieldValidator.isCIDR('8.8.0.0/12'); // true
FieldValidator.isCIDR('2001::1234:5678/128'); // true
FieldValidator.isCIDR('8.8.8.10'); // false
FieldValidator.isCIDR(['8.8.0.0/12', '2001::1234:5678/128']); // true

Source

data-mate/src/validations/field-validator.ts:595


isCountryCode()

isCountryCode(input, _parentContext?): boolean

Validates that input is a valid country code or a list of country codes

Parameters

ParameterTypeDescription
inputunknown
_parentContext?unknown-

Returns

boolean

boolean

Example

FieldValidator.isCountryCode('IS'); // true
FieldValidator.isCountryCode('ru'); // true
FieldValidator.isCountryCode('USA'); // false
FieldValidator.isCountryCode(['IS', 'ru']); // true

Source

data-mate/src/validations/field-validator.ts:1164


isEmail()

isEmail(input, _parentContext?): boolean

Return true if value is a valid email, or a list of valid emails

Parameters

ParameterTypeDescription
inputunknown
_parentContext?unknown-

Returns

boolean

boolean

Example

FieldValidator.isEmail('ha3ke5@pawnage.com') // true
FieldValidator.isEmail('user@blah.com/junk.junk?a=<tag value="junk"') // true
FieldValidator.isEmail('email@example.com'); // true
FieldValidator.isEmail(12345); // false
FieldValidator.isEmail(['email@example.com', 'ha3ke5@pawnage.com']); // true

Source

data-mate/src/validations/field-validator.ts:241


isEmpty()

isEmpty(input, _parentContext?, args?): boolean

Validates that the input is empty

Parameters

ParameterTypeDescription
inputunknown
_parentContext?unknown-
args?objectset to true if you want the value to be trimmed
args.ignoreWhitespace?boolean-

Returns

boolean

boolean

Example

FieldValidator.isEmpty(''); // true
FieldValidator.isEmpty(undefined); // true
FieldValidator.isEmpty(null); // true
FieldValidator.isEmpty({ foo: 'bar' }); // false
FieldValidator.isEmpty({}); // true
FieldValidator.isEmpty([]); // true
FieldValidator.isEmpty(' ', {}, { ignoreWhitespace: true }); // true

Source

data-mate/src/validations/field-validator.ts:1069


isFQDN()

isFQDN(input, _parentContext?, args?): boolean

Validate that the input is a valid domain name, or a list of domain names

Parameters

ParameterTypeDescription
inputunknown
_parentContext?unknown-
args?FQDNOptions-

Returns

boolean

boolean

Example

FieldValidator.isFQDN('example.com.uk'); // true
FieldValidator.isFQDN('notadomain'); // false
FieldValidator.isFQDN(['example.com.uk', 'google.com']); // true

Source

data-mate/src/validations/field-validator.ts:1095


isGeoJSON()

isGeoJSON(input, _parentContext?): boolean

Checks to see if input is a valid geo-json geometry, or a list of geo-json geometries

Parameters

ParameterTypeDescription
inputunknown
_parentContext?unknown-

Returns

boolean

boolean

Example

FieldValidator.isGeoJSON('hello'); // false

const polygon = {
type: "Polygon",
coordinates: [
[[10, 10], [10, 50], [50, 50], [50, 10], [10, 10]],
]
};
FieldValidator.isGeoJSON(polygon); // true
FieldValidator.isGeoJSON([polygon, { other: 'obj'}]); // false

Source

data-mate/src/validations/field-validator.ts:295


isGeoPoint()

isGeoPoint(input, _parentContext?): boolean

Checks to see if input is a valid geo-point, or a list of valid geo-points excluding null/undefined values

Parameters

ParameterTypeDescription
inputunknown
_parentContext?unknown-

Returns

boolean

boolean

Example

FieldValidator.isGeoPoint('60,80'); // true
FieldValidator.isGeoPoint([80, 60]); // true
FieldValidator.isGeoPoint({ lat: 60, lon: 80 }); // true
FieldValidator.isGeoPoint({ latitude: 60, longitude: 80 }); // true
FieldValidator.isGeoPoint(['60,80', { lat: 60, lon: 80 }]); // true
FieldValidator.isGeoPoint(['60,80', 'hello']); // false

Source

data-mate/src/validations/field-validator.ts:264


isGeoShapeMultiPolygon()

isGeoShapeMultiPolygon(input, _parentContext?): boolean

Checks to see if input is a valid geo-json multi-polygon or a list of geo-json multi-polygons

Parameters

ParameterTypeDescription
inputunknown
_parentContext?unknown-

Returns

boolean

boolean

Example

const polygon = {
type: "Polygon",
coordinates: [
[[10, 10], [10, 50], [50, 50], [50, 10], [10, 10]],
]
};

const point = {
type: 'Point',
coordinates: [12, 12]
};

const multiPolygon = {
type: 'MultiPolygon',
coordinates: [
[
[[10, 10], [10, 50], [50, 50], [50, 10], [10, 10]],
],
[
[[-10, -10], [-10, -50], [-50, -50], [-50, -10], [-10, -10]],
]
]
};

FieldValidator.isGeoShapeMultiPolygon(polygon); // false
FieldValidator.isGeoShapeMultiPolygon(point); // false
FieldValidator.isGeoShapeMultiPolygon(multiPolygon); // true
FieldValidator.isGeoShapeMultiPolygon([multiPolygon, multiPolygon]); // true
FieldValidator.isGeoShapeMultiPolygon([multiPolygon, point]); // false

Source

data-mate/src/validations/field-validator.ts:412


isGeoShapePoint()

isGeoShapePoint(input, _parentContext)

isGeoShapePoint(input, _parentContext?): input is GeoShapePoint

Checks to see if input is a valid geo-json point, or a list of geo-json points

Parameters
ParameterTypeDescription
inputunknown
_parentContext?unknown-
Returns

input is GeoShapePoint

boolean

Example
const polygon = {
type: "Polygon",
coordinates: [
[[10, 10], [10, 50], [50, 50], [50, 10], [10, 10]],
]
};

const point = {
type: 'Point',
coordinates: [12, 12]
};

FieldValidator.isGeoShapePoint(polygon); // false
FieldValidator.isGeoShapePoint(point); // true
FieldValidator.isGeoShapePoint([polygon, point]); // false
FieldValidator.isGeoShapePoint([point, point]); // true
Source

data-mate/src/validations/field-validator.ts:326

isGeoShapePoint(input, _parentContext)

isGeoShapePoint(input, _parentContext?): input is GeoShapePoint[]

Parameters
ParameterType
inputunknown[]
_parentContext?unknown
Returns

input is GeoShapePoint[]

Source

data-mate/src/validations/field-validator.ts:329


isGeoShapePolygon()

isGeoShapePolygon(input, _parentContext?): boolean

Checks to see if input is a valid geo-json polygon or a list of geo-json polygons

Parameters

ParameterTypeDescription
inputunknown
_parentContext?unknown-

Returns

boolean

boolean

Example

FieldValidator.isGeoShapePolygon(3); // false

const polygon = {
type: 'Polygon',
coordinates: [
[[10, 10], [10, 50], [50, 50], [50, 10], [10, 10]],
]
};

const point = {
type: 'Point',
coordinates: [12, 12]
};

FieldValidator.isGeoShapePolygon(polygon); // true
FieldValidator.isGeoShapePolygon(point); // false
FieldValidator.isGeoShapePolygon([polygon, point]); // false
FieldValidator.isGeoShapePolygon([polygon, polygon]); // true

Source

data-mate/src/validations/field-validator.ts:367


isHash()

isHash(input, _parentContext, args): boolean

Validates that the input is a hash, or a list of hashes

Parameters

ParameterTypeDescription
inputunknown
_parentContextunknown-
argsHashConfig-

Returns

boolean

boolean

Example

const md5Config = { algo: 'md5'};
const sha256Config = { algo: 'sha256' }
const sha1Config = { algo: 'sha1' }

FieldValidator.isHash('6201b3d1815444c87e00963fcf008c1e', {}, { algo: 'md5' }); // true
FieldValidator.isHash(
'85031b6f407e7f25cf826193338f7a4c2dc8c8b5130f5ca2c69a66d9f5107e33',
{},
{ algo: 'sha256' }
); // true

FieldValidator.isHash('98fc121ea4c749f2b06e4a768b92ef1c740625a0', {}, { algo: 'sha1' }); // true
FieldValidator.isHash(['6201b3d1815444c87e00963fcf008c1e', undefined],
{},
{ algo: 'md5' }
); // true

Source

data-mate/src/validations/field-validator.ts:1138


isIP()

isIP(input, _parentContext?): input is string

Validates that the input is an IP address, or a list of IP addresses

Parameters

ParameterTypeDescription
inputunknown
_parentContext?unknown-

Returns

input is string

boolean

Example

FieldValidator.isIP('8.8.8.8'); // true
FieldValidator.isIP('192.172.1.18'); // true
FieldValidator.isIP('11.0.1.18'); // true
FieldValidator.isIP('2001:db8:85a3:8d3:1319:8a2e:370:7348'); // true
FieldValidator.isIP('fe80::1ff:fe23:4567:890a%eth2'); // true
FieldValidator.isIP('2001:DB8::1'); // true
FieldValidator.isIP('172.16.0.1'); // true
FieldValidator.isIP(['172.16.0.1', '11.0.1.18']); // true

Source

data-mate/src/validations/field-validator.ts:437


isISDN()

isISDN(input, _parentContext?): boolean

Validates that the input is a valid phone number, or a list of phone numbers

Parameters

ParameterTypeDescription
inputunknown
_parentContext?unknown-

Returns

boolean

boolean

Example

FieldValidator.isISDN('46707123456'); // true
FieldValidator.isISDN('1-808-915-6800'); // true
FieldValidator.isISDN('NOT A PHONE Number'); // false
FieldValidator.isISDN(79525554602); // true
FieldValidator.isISDN(['46707123456', '1-808-915-6800']); // true

Source

data-mate/src/validations/field-validator.ts:673


isISO8601()

isISO8601(input, _parentContext?): boolean

Checks to see if input is a valid ISO8601 string dates or a list of valid dates

Parameters

ParameterTypeDescription
inputunknown
_parentContext?unknown-

Returns

boolean

boolean

Example

FieldValidator.isISO8601('2020-01-01T12:03:03.494Z'); // true
FieldValidator.isISO8601('2020-01-01'); // true
FieldValidator.isISO8601('2020-01-01T12:03:03'); // true

Source

data-mate/src/validations/field-validator.ts:1186


isISSN()

isISSN(input, _parentContext?, args?): boolean

Validates that input is a valid ISSN or a list of valid ISSN

Parameters

ParameterTypeDescription
inputunknown
_parentContext?unknown-
args?ArgsISSNOptions-

Returns

boolean

boolean

Example

FieldValidator.isISSN('0378-5955'); // true
FieldValidator.isISSN('03785955'); // true
FieldValidator.isISSN('0378-5955', {}, { requireHyphen: true }); // true
FieldValidator.isISSN(['0378-5955', '0000-006x']); // true

Source

data-mate/src/validations/field-validator.ts:1212


isInteger()

isInteger(input, _parentContext?): boolean

Validates that input is a integer or a list of integers

Parameters

ParameterTypeDescription
inputunknown
_parentContext?unknown-

Returns

boolean

boolean

Example

FieldValidator.isInteger(42); // true
FieldValidator.isInteger(3.14); // false
FieldValidator.isInteger(Infinity); // false
FieldValidator.isInteger('1'); // false
FieldValidator.isInteger(true); //false
FieldValidator.isInteger([42, 1]); // true
FieldValidator.isInteger([42, 3.14]); // false

Source

data-mate/src/validations/field-validator.ts:792


isJSON()

isJSON(input, _parentContext?): boolean

Validates that input is a valid JSON string or a list of valid JSON

Parameters

ParameterTypeDescription
inputunknown
_parentContext?unknown-

Returns

boolean

boolean

Example

FieldValidator.isJSON('{ "bob": "gibson" }'); // true
FieldValidator.isJSON({ bob: 'gibson' }); // false
FieldValidator.isJSON('[]'); // true
FieldValidator.isJSON('{}'); // true
FieldValidator.isJSON(['{ "bob": "gibson" }', '[]']); // true

Source

data-mate/src/validations/field-validator.ts:1266


isLength()

isLength(input, _parentContext, __namedParameters): boolean

Check to see if input is a string with given length ranges, or a list of valid string lengths

Parameters

ParameterTypeDescription
inputunknown
_parentContextunknown-
__namedParametersLengthConfig-

Returns

boolean

boolean

Example

FieldValidator.isLength('astring', { size: 7 }); // true
FieldValidator.isLength('astring', { min: 3, max: 10 }); // true
FieldValidator.isLength('astring', { size: 10 }); // false
FieldValidator.isLength('astring', {}, { min: 8 }); // false
FieldValidator.isLength(['astring', 'stuff', 'other'], { min: 3, max: 10 }); // true

Source

data-mate/src/validations/field-validator.ts:1291


isMACAddress()

isMACAddress(input, _parentContext?, args?): boolean

Validates that the input is a MacAddress, or a list of MacAddresses

Parameters

ParameterTypeDescription
inputunknown
_parentContext?unknown-
args?MACAddressArgs-

Returns

boolean

boolean

Example

FieldValidator.isMACAddress('00:1f:f3:5b:2b:1f'); // true
FieldValidator.isMACAddress('001ff35b2b1f'); // true
FieldValidator.isMACAddress('001f.f35b.2b1f',{}, { delimiter: 'dot' }); // true

const manyDelimiters = { delimiter: 'any' }
FieldValidator.isMACAddress('00-1f-f3-5b-2b-1f', {}, manyDelimiters); // true
FieldValidator.isMACAddress(12345); // false

// specified colon and space delimiter only
const twoDelimiters = { delimiter: 'any };
FieldValidator.isMACAddress('00-1f-f3-5b-2b-1f', {}, twoDelimiters ); // false,
FieldValidator.isMACAddress(['001ff35b2b1f', '00:1f:f3:5b:2b:1f']); // true

Source

data-mate/src/validations/field-validator.ts:714


isMIMEType()

isMIMEType(input, _parentContext?): boolean

Validates that input is a valid mimeType or a list of mimeTypes

Parameters

ParameterTypeDescription
inputunknown
_parentContext?unknown-

Returns

boolean

boolean

Example

FieldValidator.isMIMEType('application/javascript'); // true
FieldValidator.isMIMEType('application/graphql'); // true
FieldValidator.isMIMEType(12345); // false
FieldValidator.isMIMEType(['application/graphql', 'application/javascript']); // true

Source

data-mate/src/validations/field-validator.ts:1327


isNonRoutableIP()

isNonRoutableIP(input, _parentContext?): boolean

Validate is input is a non-routable IP, or a list of non-routable IP's

Parameters

ParameterTypeDescription
inputunknown
_parentContext?unknown-

Returns

boolean

boolean

see: https://www.iana.org/assignments/iana-ipv4-special-registry/iana-ipv4-special-registry.xhtml https://www.iana.org/assignments/iana-ipv6-special-registry/iana-ipv6-special-registry.xhtml for ip range details

Example

FieldValidator.isNonRoutableIP('192.168.0.1'); // true
FieldValidator.isNonRoutableIP('10.16.32.210'); // true
FieldValidator.isNonRoutableIP('fc00:db8::1'); // true
FieldValidator.isNonRoutableIP('8.8.8.8'); // false
FieldValidator.isNonRoutableIP('2001:db8::1'); // false
FieldValidator.isNonRoutableIP(['10.16.32.210', '192.168.0.1']); // true

Source

data-mate/src/validations/field-validator.ts:506


isNumber()

isNumber(input, _parentContext?): input is number

Validates that input is a number or a list of numbers

Parameters

ParameterTypeDescription
inputunknown
_parentContext?unknown-

Returns

input is number

boolean

Example

FieldValidator.isNumber(42.32); // true
FieldValidator.isNumber('NOT A Number'); // false
FieldValidator.isNumber([42.32, 245]); // true
FieldValidator.isNumber([42.32, { some: 'obj' }]); // false
FieldValidator.isNumber('1'); // false

Source

data-mate/src/validations/field-validator.ts:769


isNumberTuple()

isNumberTuple(input, _parentContext?): boolean

Parameters

ParameterType
inputunknown
_parentContext?unknown

Returns

boolean

Source

data-mate/src/validations/field-validator.ts:1498


isPostalCode()

isPostalCode(input, _parentContext, args): boolean

Validates that input is a valid postal code or a list of postal codes

Parameters

ParameterTypeDescription
inputunknown
_parentContextunknown-
argsobject-
args.localePostalCodeLocale | "any"-

Returns

boolean

boolean

Example

FieldValidator.isPostalCode('85249'); // true
FieldValidator.isPostalCode('85249', {}, { locale: 'any' }); // true
FieldValidator.isPostalCode('85249', {}, { locale: 'ES' }); // false
FieldValidator.isPostalCode('852', {}, { locale: 'IS' }); // true
FieldValidator.isPostalCode('885 49', {}, { locale: 'SE' }); // true
FieldValidator.isPostalCode(1234567890); // false
FieldValidator.isPostalCode(['85249']); // true

Source

data-mate/src/validations/field-validator.ts:1356


isRFC3339()

isRFC3339(input, _parentContext?): boolean

Validates that input is a valid RFC3339 dates or a list of valid RFC3339 dates

Parameters

ParameterTypeDescription
inputunknown
_parentContext?unknown-

Returns

boolean

boolean

Example

FieldValidator.isRFC3339('2020-01-01T12:05:05.001Z'); // true
FieldValidator.isRFC3339('2020-01-01 12:05:05.001Z'); // true
FieldValidator.isRFC3339('2020-01-01T12:05:05Z'); // true
FieldValidator.isRFC3339(['2020-01-01T12:05:05Z', '2020-01-01T12:05:05.001Z']); // true

Source

data-mate/src/validations/field-validator.ts:1241


isRoutableIP()

isRoutableIP(input, _parentContext?): boolean

Validate is input is a routable IP, or a list of routable IP's

Parameters

ParameterTypeDescription
inputunknown
_parentContext?unknown-

Returns

boolean

boolean

see: https://www.iana.org/assignments/iana-ipv4-special-registry/iana-ipv4-special-registry.xhtml https://www.iana.org/assignments/iana-ipv6-special-registry/iana-ipv6-special-registry.xhtml for ip range details

Example

FieldValidator.isRoutableIP('8.8.8.8'); // true
FieldValidator.isRoutableIP('2001:db8::1'); // true
FieldValidator.isRoutableIP('172.194.0.1'); // true
FieldValidator.isRoutableIP('100.127.255.250'); // false
FieldValidator.isRoutableIP('192.168.0.1'); // false
FieldValidator.isRoutableIP(['172.194.0.1', '8.8.8.8']); // true

Source

data-mate/src/validations/field-validator.ts:472


isString()

isString(input, _parentContext?): input is string

Validates that input is a string or a list of strings

Parameters

ParameterTypeDescription
inputunknown
_parentContext?unknown-

Returns

input is string

Example

FieldValidator.isString('this is a string'); // true
FieldValidator.isString(true); // false
FieldValidator.isString(['hello', 'world']); // true
FieldValidator.isString(['hello', 3]); // false
FieldValidator.isString(17.343); // false

Source

data-mate/src/validations/field-validator.ts:812


isURL()

isURL(input, _parentContext?): boolean

Validates that the input is a url or a list of urls

Parameters

ParameterTypeDescription
inputunknown
_parentContext?unknown-

Returns

boolean

boolean

Example

FieldValidator.isURL('https://someurl.cc.ru.ch'); // true
FieldValidator.isURL('ftp://someurl.bom:8080?some=bar&hi=bob'); // true
FieldValidator.isURL('http://xn--fsqu00a.xn--3lr804guic'); // true
FieldValidator.isURL('http://example.com'); // true
FieldValidator.isURL('BAD-URL'); // false
FieldValidator.isURL(['http://example.com', 'http://example.com']); // true

Source

data-mate/src/validations/field-validator.ts:834


isUUID()

isUUID(input, _parentContext?): boolean

Validates that input is a UUID or a list of UUID's

Parameters

ParameterTypeDescription
inputunknown
_parentContext?unknown-

Returns

boolean

boolean

Example

FieldValidator.isUUID('0668CF8B-27F8-2F4D-4F2D-763AC7C8F68B'); // true
FieldValidator.isUUID('BAD-UUID'); // false
FieldValidator.isUUID([
'0668CF8B-27F8-2F4D-4F2D-763AC7C8F68B',
'123e4567-e89b-82d3-f456-426655440000'
]); // true

Source

data-mate/src/validations/field-validator.ts:860


isValidDate()

isValidDate(input, _parentContext?): boolean

Validates that the input is a valid date or a list of valid dates

Parameters

ParameterTypeDescription
inputunknown
_parentContext?unknown-

Returns

boolean

boolean

Example

FieldValidator.isValidDate('2019-03-17T23:08:59.673Z'); // true
FieldValidator.isValidDate('2019-03-17'); // true
FieldValidator.isValidDate('2019-03-17T23:08:59'); // true
FieldValidator.isValidDate('03/17/2019'); // true
FieldValidator.isValidDate('03-17-2019'); // true
FieldValidator.isValidDate('Jan 22, 2012'); // true
FieldValidator.isValidDate('23 Jan 2012'); // true
FieldValidator.isValidDate(1552000139); // true
FieldValidator.isValidDate('1552000139'); // false
FieldValidator.isValidDate(['2019-03-17', 1552000139]); // true;

Source

data-mate/src/validations/field-validator.ts:1387


some()

some(input, _parentContext, __namedParameters): boolean

Validates that the function specified returns true at least once on the list of values

Parameters

ParameterTypeDescription
inputunknown
_parentContextunknown-
__namedParametersobject-
__namedParameters.fnstring-
__namedParameters.options?any-

Returns

boolean

boolean

Example

const mixedArray = ['hello', 3, { some: 'obj' }];
FieldValidator.some(mixedArray, mixedArray, fn: 'isString' }); // true
FieldValidator.some(mixedArray, mixedArray, { fn: 'isBoolean' }); // false

Source

data-mate/src/validations/field-validator.ts:1460