Skip to main content

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

validations/record-validator

Variables

repository

const repository: Repository

Source

data-mate/src/validations/record-validator.ts:8

Functions

reject()

reject(input, _parentContext, args): RecordInput | null

Will return true if an object DOES NOT match the xLucene expression * *

Parameters

ParameterTypeDescription
inputRecordInput-
_parentContextRecordInput-
argsDMOptions

* shape is { query: string, type_config: xLuceneTypeConfig, variables: xLuceneVariables }

*

Returns

RecordInput | null

boolean

Example

* const obj1 = { foo: 'hello', bar: 'stuff' };
* const obj2 = { foo: 123412 };
* const args = { query: '_exists_:bar' };
*
* const results1 = RecordValidator.reject(obj1, obj1, args);
* const results2 = RecordValidator.reject(obj2, obj2, args);
*
* results1; // false;
* results2; // true;
*
*

Source

data-mate/src/validations/record-validator.ts:185


required()

required(input, _parentContext, args): RecordInput | null

This function will return false if input record does not have all specified keys

Parameters

ParameterType
inputRecordInput
_parentContextRecordInput
argsobject
args.fieldsstring[]

Returns

RecordInput | null

boolean

Example

const obj1 = { foo: 'hello', bar: 'stuff' };
const obj2 = { foo: 123412 };
const fields = ['bar'];

const results1 = RecordValidator.required(obj1, obj1, { fields });
const results2 = RecordValidator.required(obj2, obj2, { fields });

results1; // true;
results2; // false;

Source

data-mate/src/validations/record-validator.ts:79


select()

select(input, _parentContext, args): RecordInput | null

Will return true if an object matches the xLucene expression

Parameters

ParameterTypeDescription
inputRecordInput-
_parentContextRecordInput-
argsDMOptionsshape is { query: string, type_config: xLuceneTypeConfig, variables: xLuceneVariables }

Returns

RecordInput | null

boolean

Example

const obj1 = { foo: 'hello', bar: 'stuff' };
const obj2 = { foo: 123412 };
const args = { query: '_exists_:bar' };

const results1 = RecordValidator.select(obj1, obj1, args);
const results2 = RecordValidator.select(obj2, obj2, args);

results1; // true;
results2; // false;

Source

data-mate/src/validations/record-validator.ts:132