Data-Mate: `Validations Record Validator`
Table of contents
Variables
Functions
Variables
repository
• Const
repository: Repository
Defined in
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
Name | Type | Description |
---|---|---|
input | RecordInput | - |
_parentContext | RecordInput | - |
args | DMOptions | * 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;
*
*
Defined in
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
Name | Type |
---|---|
input | RecordInput |
_parentContext | RecordInput |
args | Object |
args.fields | string [] |
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;
Defined in
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
Name | Type | Description |
---|---|---|
input | RecordInput | - |
_parentContext | RecordInput | - |
args | DMOptions | 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.select(obj1, obj1, args);
const results2 = RecordValidator.select(obj2, obj2, args);
results1; // true;
results2; // false;