Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private joinParser(data: string): QueryJoin {
const param = data.split(this._options.delim);
const join: QueryJoin = {
field: param[0],
select: isStringFull(param[1]) ? param[1].split(this._options.delimStr) : undefined,
};
validateJoin(join);
return join;
}
joinParser(data) {
const param = data.split(this._options.delim);
const join = {
field: param[0],
select: util_1.isStringFull(param[1]) ? param[1].split(this._options.delimStr) : undefined,
};
request_query_validator_1.validateJoin(join);
return join;
}
sortParser(data) {
export function validateSort(sort: QuerySort): void {
if (!isObject(sort) || !isStringFull(sort.field)) {
throw new RequestQueryException('Invalid sort field. String expected');
}
if (
!isEqual(sort.order, sortOrdersList[0]) &&
!isEqual(sort.order, sortOrdersList[1])
) {
throw new RequestQueryException(`Invalid sort order. ${sortOrdersListStr} expected`);
}
}
function validateSort(sort) {
if (!util_1.isObject(sort) || !util_1.isStringFull(sort.field)) {
throw new exceptions_1.RequestQueryException('Invalid sort field. String expected');
}
if (!util_1.isEqual(sort.order, exports.sortOrdersList[0]) &&
!util_1.isEqual(sort.order, exports.sortOrdersList[1])) {
throw new exceptions_1.RequestQueryException(`Invalid sort order. ${sortOrdersListStr} expected`);
}
}
exports.validateSort = validateSort;
getParamValues(value, parser) {
if (util_1.isStringFull(value)) {
return [parser.call(this, value)];
}
if (util_1.isArrayFull(value)) {
return value.map((val) => parser(val));
}
return [];
}
parseQueryParam(type, parser) {
private getParamValues(value: string | string[], parser: Function): string[] {
if (isStringFull(value)) {
return [parser.call(this, value)];
}
if (isArrayFull(value)) {
return (value as string[]).map((val) => parser(val));
}
return [];
}
export function validateCondition(
val: QueryFilter,
cond: 'filter' | 'or' | 'search',
): void {
if (!isObject(val) || !isStringFull(val.field)) {
throw new RequestQueryException(
`Invalid field type in ${cond} condition. String expected`,
);
}
validateComparisonOperator(val.operator);
}
export function validateJoin(join: QueryJoin): void {
if (!isObject(join) || !isStringFull(join.field)) {
throw new RequestQueryException('Invalid join field. String expected');
}
if (!isUndefined(join.select) && !isArrayStrings(join.select)) {
throw new RequestQueryException('Invalid join select. Array of strings expected');
}
}
function validateJoin(join) {
if (!util_1.isObject(join) || !util_1.isStringFull(join.field)) {
throw new exceptions_1.RequestQueryException('Invalid join field. String expected');
}
if (!util_1.isUndefined(join.select) && !util_1.isArrayStrings(join.select)) {
throw new exceptions_1.RequestQueryException('Invalid join select. Array of strings expected');
}
}
exports.validateJoin = validateJoin;