How to use the @nestjsx/util.hasValue function in @nestjsx/util

To help you get started, we’ve selected a few @nestjsx/util examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nestjsx / crud / packages / crud-request / src / request-query.parser.ts View on Github external
'$inL',
      '$notinL',
    ];
    const isEmptyValue = ['isnull', 'notnull', '$isnull', '$notnull'];
    const param = data.split(this._options.delim);
    const field = param[0];
    const operator = param[1] as ComparisonOperator;
    let value = param[2] || '';

    if (isArrayValue.some((name) => name === operator)) {
      value = value.split(this._options.delimStr) as any;
    }

    value = this.parseValues(value);

    if (!isEmptyValue.some((name) => name === operator) && !hasValue(value)) {
      throw new RequestQueryException(`Invalid ${cond} value`);
    }

    const condition: QueryFilter = { field, operator, value };
    validateCondition(condition, cond);

    return condition;
  }
github nestjsx / crud / packages / crud-request / src / request-query.builder.ts View on Github external
cond(
    f: QueryFilter | QueryFilterArr,
    cond: 'filter' | 'or' | 'search' = 'search',
  ): string {
    const filter = Array.isArray(f) ? { field: f[0], operator: f[1], value: f[2] } : f;
    validateCondition(filter, cond);
    const d = this.options.delim;

    return (
      filter.field +
      d +
      filter.operator +
      (hasValue(filter.value) ? d + filter.value : '')
    );
  }