export function isConditionExpressionPredicate()

in packages/dynamodb-expressions/src/ConditionExpression.ts [278:309]


export function isConditionExpressionPredicate(
    arg: any
): arg is ConditionExpressionPredicate {
    if (arg && typeof arg === 'object') {
        switch (arg.type) {
            case 'Equals':
            case 'NotEquals':
            case 'LessThan':
            case 'LessThanOrEqualTo':
            case 'GreaterThan':
            case 'GreaterThanOrEqualTo':
                return arg.object !== undefined;
            case 'Between':
                return arg.lowerBound !== undefined
                    && arg.upperBound !== undefined;
            case 'Membership':
                return Array.isArray(arg.values);
            case 'Function':
                switch (arg.name) {
                    case 'attribute_exists':
                    case 'attribute_not_exists':
                        return true;
                    case 'attribute_type':
                    case 'begins_with':
                    case 'contains':
                        return typeof arg.expected === 'string';
                }
        }
    }

    return false;
}