Skip to main content

PartialValidator

@webda/ql


Class: PartialValidator

Defined in: packages/ql/src/query.ts:1659

A query validator that supports partial object matching

In partial mode, comparisons against undefined attributes evaluate to true (the missing field is ignored). This is useful for PATCH operations where only a subset of fields is provided.

Example​

const v = new PartialValidator("name = 'John' AND age > 18");
v.eval({ name: "John" }); // true (age is undefined, skipped)
v.wasPartialMatch(); // true
v.eval({ name: "John" }, false); // false (strict mode, age required)

Extends​

Constructors​

Constructor​

new PartialValidator(query, builder?): PartialValidator

Defined in: packages/ql/src/query.ts:1666

Parameters​

query​

string

WebdaQL query string

builder?​

PartialExpressionBuilder = ...

partial expression builder (override for customization)

Returns​

PartialValidator

Overrides​

QueryValidator.constructor

Properties​

builder​

builder: PartialExpressionBuilder

Defined in: packages/ql/src/query.ts:1660

Overrides​

QueryValidator.builder


lexer​

protected lexer: WebdaQLLexer

Defined in: packages/ql/src/query.ts:1412

Inherited from​

QueryValidator.lexer


query​

protected query: Query

Defined in: packages/ql/src/query.ts:1414

Inherited from​

QueryValidator.query


sql​

protected sql: string

Defined in: packages/ql/src/query.ts:1425

the query string to parse

Inherited from​

QueryValidator.sql


tree​

protected tree: WebdaqlContext

Defined in: packages/ql/src/query.ts:1413

Inherited from​

QueryValidator.tree

Methods​

displayTree()​

displayTree(tree?): string

Defined in: packages/ql/src/query.ts:1568

Display parse tree back as query

Parameters​

tree?​

ParseTree = ...

the parse tree to display

Returns​

string

the query string representation

Inherited from​

QueryValidator.displayTree


eval()​

eval(target, partial?): boolean

Defined in: packages/ql/src/query.ts:1676

Eval the query

Parameters​

target​

any

the object to evaluate

partial?​

boolean = true

whether to use partial matching

Returns​

boolean

true if the target matches

Overrides​

QueryValidator.eval


getExpression()​

getExpression(): Expression

Defined in: packages/ql/src/query.ts:1531

Get the filter expression (without LIMIT / OFFSET / ORDER BY)

Returns​

Expression

the filter expression

Inherited from​

QueryValidator.getExpression


getLimit()​

getLimit(): number

Defined in: packages/ql/src/query.ts:1523

Get parsed LIMIT value, defaulting to 1000

Returns​

number

the limit value

Inherited from​

QueryValidator.getLimit


getOffset()​

getOffset(): string

Defined in: packages/ql/src/query.ts:1440

Get parsed OFFSET continuation token, or empty string if none

Returns​

string

the offset token

Inherited from​

QueryValidator.getOffset


getQuery()​

getQuery(): Query

Defined in: packages/ql/src/query.ts:1539

Retrieve the full parsed query including filter, limit, offset, and orderBy

Returns​

Query

the full query object

Inherited from​

QueryValidator.getQuery


hasCondition()​

hasCondition(): boolean

Defined in: packages/ql/src/query.ts:1450

Check whether the query has a non-empty filter condition

An empty AND expression (no children) is considered to have no condition.

Returns​

boolean

true if there is a filter condition

Inherited from​

QueryValidator.hasCondition


isDynamic()​

isDynamic(): boolean

Defined in: packages/ql/src/query.ts:1559

Check whether this query's filter contains any dynamic values

Returns​

boolean

true if any child comparison holds a DynamicValue

Inherited from​

QueryValidator.isDynamic


merge()​

merge(query?, type?): this

Defined in: packages/ql/src/query.ts:1479

Merge another query string into this query

Filter expressions are combined using the specified logical operator. LIMIT, OFFSET, and ORDER BY from the merged query override existing values.

Parameters​

query?​

string = ""

query string to merge in

type?​

"AND" | "OR" = "AND"

logical operator to combine filters ("AND" or "OR")

Returns​

this

this for chaining

Inherited from​

QueryValidator.merge


toString()​

toString(): string

Defined in: packages/ql/src/query.ts:1465

Reconstruct the query string from the parsed AST

Includes filter, ORDER BY, LIMIT, and OFFSET clauses.

Returns​

string

the reconstructed query string

Inherited from​

QueryValidator.toString


wasPartialMatch()​

wasPartialMatch(): boolean

Defined in: packages/ql/src/query.ts:1686

Return if the result ignored some fields

Returns​

boolean

true if some fields were skipped