Skip to main content

ValueProcessorOptions

Defined in: packages/react-querybuilder/src/types/importExport.ts:222

Options object for ValueProcessorByRule functions.

Extends

Properties

concatOperator?

optional concatOperator: string & {} | "||" | "+" | "CONCAT"

Defined in: packages/react-querybuilder/src/types/importExport.ts:210

Operator to use when concatenating wildcard characters and field names in "sql" format. The ANSI standard is ||, while SQL Server uses +. MySQL does not implement a concatenation operator by default, and therefore requires use of the CONCAT function.

If concatOperator is set to "CONCAT" (case-insensitive), the CONCAT function will be used. Note that Oracle SQL does not support more than two values in the CONCAT function, so this option should not be used in that context. The default setting ("||") is already compatible with Oracle SQL.

Default

'||'

Inherited from

FormatQueryOptions.concatOperator


context?

optional context: Record<string, any>

Defined in: packages/react-querybuilder/src/types/importExport.ts:216

Inherited from

FormatQueryOptions.context


escapeQuotes?

optional escapeQuotes: boolean

Defined in: packages/react-querybuilder/src/types/importExport.ts:224


fallbackExpression?

optional fallbackExpression: string

Defined in: packages/react-querybuilder/src/types/importExport.ts:141

This string will be inserted in place of invalid groups for non-JSON formats. Defaults to '(1 = 1)' for "sql"/"parameterized"/"parameterized_named" and '$and:[{$expr:true}]' for "mongodb".

Inherited from

FormatQueryOptions.fallbackExpression


fieldData?

optional fieldData: { [key: string]: unknown; className: Classname; comparator: string | (f: { [key: string]: unknown; className: Classname; comparator: string | ((f: { [x: string]: unknown; label: string; disabled?: boolean | undefined; name: string; value: string; id?: string | undefined; operators?: FlexibleOptionList<{ [x: string]: unknown; value?: string | undefined; label: string; disabled?: boolean | undefined; name: string; }> | undefined; ... 9 more ...; cl...; defaultOperator: string; defaultValue: any; disabled: boolean; id: string; inputType: null | InputType; label: string; name: string; operators: FlexibleOptionList<{ [key: string]: unknown; disabled: boolean; label: string; name: string; value: string; }>; placeholder: string; validator: RuleValidator; value: string; valueEditorType: ValueEditorType | (operator: string) => ValueEditorType; values: FlexibleOptionList<{ [key: string]: unknown; disabled: boolean; label: string; name: string; value: string; }>; valueSources: ValueSources | (operator: string) => ValueSources; }, operator: string) => boolean; defaultOperator: string; defaultValue: any; disabled: boolean; id: string; inputType: null | InputType; label: string; name: string; operators: FlexibleOptionList<{ [key: string]: unknown; disabled: boolean; label: string; name: string; value: string; }>; placeholder: string; validator: RuleValidator; value: string; valueEditorType: ValueEditorType | (operator: string) => ValueEditorType; values: FlexibleOptionList<{ [key: string]: unknown; disabled: boolean; label: string; name: string; value: string; }>; valueSources: ValueSources | (operator: string) => ValueSources; }

Defined in: packages/react-querybuilder/src/types/importExport.ts:229

The full field object, if fields was provided in the formatQuery options parameter.

Index Signature

[key: string]: unknown

className?

optional className: Classname

comparator?

optional comparator: string | (f: { [key: string]: unknown; className: Classname; comparator: string | ((f: { [x: string]: unknown; label: string; disabled?: boolean | undefined; name: string; value: string; id?: string | undefined; operators?: FlexibleOptionList<{ [x: string]: unknown; value?: string | undefined; label: string; disabled?: boolean | undefined; name: string; }> | undefined; ... 9 more ...; cl...; defaultOperator: string; defaultValue: any; disabled: boolean; id: string; inputType: null | InputType; label: string; name: string; operators: FlexibleOptionList<{ [key: string]: unknown; disabled: boolean; label: string; name: string; value: string; }>; placeholder: string; validator: RuleValidator; value: string; valueEditorType: ValueEditorType | (operator: string) => ValueEditorType; values: FlexibleOptionList<{ [key: string]: unknown; disabled: boolean; label: string; name: string; value: string; }>; valueSources: ValueSources | (operator: string) => ValueSources; }, operator: string) => boolean

defaultOperator?

optional defaultOperator: string

defaultValue?

optional defaultValue: any

disabled?

optional disabled: boolean

id?

optional id: string

inputType?

optional inputType: null | InputType

label

label: string

name

name: string

operators?

optional operators: FlexibleOptionList<{ [key: string]: unknown; disabled: boolean; label: string; name: string; value: string; }>

placeholder?

optional placeholder: string

validator?

optional validator: RuleValidator

value

value: string

valueEditorType?

optional valueEditorType: ValueEditorType | (operator: string) => ValueEditorType

values?

optional values: FlexibleOptionList<{ [key: string]: unknown; disabled: boolean; label: string; name: string; value: string; }>

valueSources?

optional valueSources: ValueSources | (operator: string) => ValueSources


fieldIdentifierSeparator?

optional fieldIdentifierSeparator: string

Defined in: packages/react-querybuilder/src/types/importExport.ts:107

When used in conjunction with the quoteFieldNamesWith option, field names will be split by this string, each part being individually processed as per the rules of the quoteFieldNamesWith configuration. The parts will then be re-joined by the same string.

A common value for this option is '.'.

A value of '' (the empty string) will disable splitting/rejoining.

Default

''

Example

formatQuery(query, {
format: 'sql',
quoteFieldNamesWith: ['[', ']'],
fieldIdentifierSeparator: '.',
})
// "[dbo].[Musicians].[First name] = 'Steve'"

Inherited from

FormatQueryOptions.fieldIdentifierSeparator


fieldParamNames?

optional fieldParamNames: Record<string, string[]>

Defined in: packages/react-querybuilder/src/types/importExport.ts:236

Included for the "parameterized_named" format only. Keys of this object represent field names and values represent the current list of parameter names for that field based on the query rules processed up to that point. Use this list to ensure that parameter names generated by the custom rule processor are unique.


fields?

optional fields: FlexibleOptionList<{ [key: string]: unknown; className: Classname | undefined; comparator: string | (f: { [key: string]: unknown; className: Classname | undefined; comparator: string | ((f: { [x: string]: unknown; label: string; disabled?: boolean | undefined; name: string; value: string; id?: string | undefined; operators?: FlexibleOptionList<{ [x: string]: unknown; value?: string | undefined; label: string; disabled?: boolean | undefined; name: string; }> | undefined; ... 9 more ...; cl...; defaultOperator: string; defaultValue: any; disabled: boolean; id: string; inputType: InputType | null | undefined; label: string; name: string; operators: FlexibleOptionList<{ [x: string]: unknown; value?: string | undefined; label: string; disabled?: boolean | undefined; name: string; }> | undefined; placeholder: string; validator: RuleValidator; value: string; valueEditorType: ValueEditorType | ((operator: string) => ValueEditorType) | undefined; values: FlexibleOptionList<{ [x: string]: unknown; value?: string | undefined; label: string; disabled?: boolean | undefined; name: string; }> | undefined; valueSources: ValueSources | ((operator: string) => ValueSources) | undefined; }, operator: string) => boolean; defaultOperator: string; defaultValue: any; disabled: boolean; id: string; inputType: InputType | null | undefined; label: string; name: string; operators: FlexibleOptionList<{ [x: string]: unknown; value?: string | undefined; label: string; disabled?: boolean | undefined; name: string; }> | undefined; placeholder: string; validator: RuleValidator; value: string; valueEditorType: ValueEditorType | ((operator: string) => ValueEditorType) | undefined; values: FlexibleOptionList<{ [x: string]: unknown; value?: string | undefined; label: string; disabled?: boolean | undefined; name: string; }> | undefined; valueSources: ValueSources | ((operator: string) => ValueSources) | undefined; }>

Defined in: packages/react-querybuilder/src/types/importExport.ts:125

This can be the same FullField array passed to QueryBuilder, but really all you need to provide is the name and validator for each field.

The full field object from this array, where the field's identifying property matches the rule's field, will be passed to the rule processor.

Inherited from

FormatQueryOptions.fields


format?

optional format: ExportFormat

Defined in: packages/react-querybuilder/src/types/importExport.ts:49

The ExportFormat.

Inherited from

FormatQueryOptions.format


getNextNamedParam()?

optional getNextNamedParam: (field: string) => string

Defined in: packages/react-querybuilder/src/types/importExport.ts:241

Included for the "parameterized_named" format only. Call this function with a field name to get a unique parameter name, as yet unused during query processing.

Parameters

ParameterType
fieldstring

Returns

string


numberedParams?

optional numberedParams: boolean

Defined in: packages/react-querybuilder/src/types/importExport.ts:173

Renders parameter placeholders as a series of sequential numbers instead of '?' like the default. This option will respect the paramPrefix option like the 'parameterized_named' format.

Default

false

Inherited from

FormatQueryOptions.numberedParams


operatorProcessor?

optional operatorProcessor: RuleProcessor

Defined in: packages/react-querybuilder/src/types/importExport.ts:55

This function will be used to process the operator from each rule for query language formats. If not defined, the appropriate defaultOperatorProcessor* for the format will be used.

Inherited from

FormatQueryOptions.operatorProcessor


paramPrefix?

optional paramPrefix: string

Defined in: packages/react-querybuilder/src/types/importExport.ts:148

This string will be placed in front of named parameters (aka bind variables) when using the "parameterized_named" export format.

Default

":"

Inherited from

FormatQueryOptions.paramPrefix


paramsKeepPrefix?

optional paramsKeepPrefix: boolean

Defined in: packages/react-querybuilder/src/types/importExport.ts:165

Maintains the parameter prefix in the params object keys when using the "parameterized_named" export format. Recommended when using SQLite.

Default

false

Example

console.log(formatQuery(query, {
format: "parameterized_named",
paramPrefix: "$",
paramsKeepPrefix: true
}).params)
// { $firstName: "Stev" }
// Default (`paramsKeepPrefix` is `false`):
// { firstName: "Stev" }

Inherited from

FormatQueryOptions.paramsKeepPrefix


parseNumbers?

optional parseNumbers: boolean

Defined in: packages/react-querybuilder/src/types/importExport.ts:253

Parse numbers in the rule value.

Default

false

Overrides

FormatQueryOptions.parseNumbers


placeholderFieldName?

optional placeholderFieldName: string

Defined in: packages/react-querybuilder/src/types/importExport.ts:191

Any rules where the field is equal to this value will be ignored.

Default

'~'

Inherited from

FormatQueryOptions.placeholderFieldName


placeholderOperatorName?

optional placeholderOperatorName: string

Defined in: packages/react-querybuilder/src/types/importExport.ts:197

Any rules where the operator is equal to this value will be ignored.

Default

'~'

Inherited from

FormatQueryOptions.placeholderOperatorName


preserveValueOrder?

optional preserveValueOrder: boolean

Defined in: packages/react-querybuilder/src/types/importExport.ts:178

Preserves the order of values for "between" and "notBetween" rules, even if a larger value comes before a smaller value (which will always evaluate to false).

Inherited from

FormatQueryOptions.preserveValueOrder


preset?

optional preset: SQLPreset

Defined in: packages/react-querybuilder/src/types/importExport.ts:214

Option presets to maximize compatibility with various SQL dialects.

Inherited from

FormatQueryOptions.preset


quoteFieldNamesWith?

optional quoteFieldNamesWith: string | [string, string]

Defined in: packages/react-querybuilder/src/types/importExport.ts:86

In the "sql", "parameterized", "parameterized_named", and "jsonata" export formats, field names will be bracketed by this string. If an array of strings is passed, field names will be preceded by the first element and succeeded by the second element.

Tip: Use fieldIdentifierSeparator to bracket identifiers individually within field names.

Default

'' // the empty string

Examples

formatQuery(query, { format: 'sql', quoteFieldNamesWith: '"' })
// `"First name" = 'Steve'`
formatQuery(query, { format: 'sql', quoteFieldNamesWith: ['[', ']'] })
// "[First name] = 'Steve'"

Inherited from

FormatQueryOptions.quoteFieldNamesWith


quoteValuesWith?

optional quoteValuesWith: string

Defined in: packages/react-querybuilder/src/types/importExport.ts:112

Character to use for quoting string values in the SQL format.

Default

'

Inherited from

FormatQueryOptions.quoteValuesWith


ruleProcessor?

optional ruleProcessor: RuleProcessor

Defined in: packages/react-querybuilder/src/types/importExport.ts:67

This function will be used to process each rule for query language formats. If not defined, the appropriate defaultRuleProcessor* for the format will be used.

Inherited from

FormatQueryOptions.ruleProcessor


validator?

optional validator: QueryValidator

Defined in: packages/react-querybuilder/src/types/importExport.ts:117

Validator function for the entire query. Can be the same function passed as validator prop to QueryBuilder.

Inherited from

FormatQueryOptions.validator


valueProcessor?

optional valueProcessor: ValueProcessorByRule

Defined in: packages/react-querybuilder/src/types/importExport.ts:223

This function will be used to process the value from each rule for query language formats. If not defined, the appropriate defaultValueProcessor* for the format will be used.

Overrides

FormatQueryOptions.valueProcessor


wrapValueWith?

optional wrapValueWith: [string, string]

Defined in: packages/react-querybuilder/src/types/importExport.ts:247

Additional prefix and suffix characters to wrap the value in. Useful for augmenting the default value processor results with special syntax (e.g., for dates or function calls).

Methods

getOperators()?

optional getOperators(field: string, misc: { fieldData: { [key: string]: unknown; className: Classname; comparator: string | (f: { [key: string]: unknown; className: Classname; comparator: string | ((f: { [x: string]: unknown; label: string; disabled?: boolean | undefined; name: string; value: string; id?: string | undefined; operators?: FlexibleOptionList<{ [x: string]: unknown; value?: string | undefined; label: string; disabled?: boolean | undefined; name: string; }> | undefined; ... 9 more ...; cl...; defaultOperator: string; defaultValue: any; disabled: boolean; id: string; inputType: null | InputType; label: string; name: string; operators: FlexibleOptionList<{ [key: string]: unknown; disabled: boolean; label: string; name: string; value: string; }>; placeholder: string; validator: RuleValidator; value: string; valueEditorType: ValueEditorType | (operator: string) => ValueEditorType; values: FlexibleOptionList<{ [key: string]: unknown; disabled: boolean; label: string; name: string; value: string; }>; valueSources: ValueSources | (operator: string) => ValueSources; }, operator: string) => boolean; defaultOperator: string; defaultValue: any; disabled: boolean; id: string; inputType: null | InputType; label: string; name: string; operators: FlexibleOptionList<{ [key: string]: unknown; disabled: boolean; label: string; name: string; value: string; }>; placeholder: string; validator: RuleValidator; value: string; valueEditorType: ValueEditorType | (operator: string) => ValueEditorType; values: FlexibleOptionList<{ [key: string]: unknown; disabled: boolean; label: string; name: string; value: string; }>; valueSources: ValueSources | (operator: string) => ValueSources; }; }): null | FlexibleOptionList<FullOperator<string>>

Defined in: packages/react-querybuilder/src/types/importExport.ts:132

This can be the same getOperators function passed to QueryBuilder.

The full operator object from this array, where the operator's identifying property matches the rule's operator, will be passed to the rule processor.

Parameters

ParameterType
fieldstring
misc{ fieldData: { [key: string]: unknown; className: Classname; comparator: string | (f: { [key: string]: unknown; className: Classname; comparator: string | ((f: { [x: string]: unknown; label: string; disabled?: boolean | undefined; name: string; value: string; id?: string | undefined; operators?: FlexibleOptionList<{ [x: string]: unknown; value?: string | undefined; label: string; disabled?: boolean | undefined; name: string; }> | undefined; ... 9 more ...; cl...; defaultOperator: string; defaultValue: any; disabled: boolean; id: string; inputType: null | InputType; label: string; name: string; operators: FlexibleOptionList<{ [key: string]: unknown; disabled: boolean; label: string; name: string; value: string; }>; placeholder: string; validator: RuleValidator; value: string; valueEditorType: ValueEditorType | (operator: string) => ValueEditorType; values: FlexibleOptionList<{ [key: string]: unknown; disabled: boolean; label: string; name: string; value: string; }>; valueSources: ValueSources | (operator: string) => ValueSources; }, operator: string) => boolean; defaultOperator: string; defaultValue: any; disabled: boolean; id: string; inputType: null | InputType; label: string; name: string; operators: FlexibleOptionList<{ [key: string]: unknown; disabled: boolean; label: string; name: string; value: string; }>; placeholder: string; validator: RuleValidator; value: string; valueEditorType: ValueEditorType | (operator: string) => ValueEditorType; values: FlexibleOptionList<{ [key: string]: unknown; disabled: boolean; label: string; name: string; value: string; }>; valueSources: ValueSources | (operator: string) => ValueSources; }; }
misc.fieldData{ [key: string]: unknown; className: Classname; comparator: string | (f: { [key: string]: unknown; className: Classname; comparator: string | ((f: { [x: string]: unknown; label: string; disabled?: boolean | undefined; name: string; value: string; id?: string | undefined; operators?: FlexibleOptionList<{ [x: string]: unknown; value?: string | undefined; label: string; disabled?: boolean | undefined; name: string; }> | undefined; ... 9 more ...; cl...; defaultOperator: string; defaultValue: any; disabled: boolean; id: string; inputType: null | InputType; label: string; name: string; operators: FlexibleOptionList<{ [key: string]: unknown; disabled: boolean; label: string; name: string; value: string; }>; placeholder: string; validator: RuleValidator; value: string; valueEditorType: ValueEditorType | (operator: string) => ValueEditorType; values: FlexibleOptionList<{ [key: string]: unknown; disabled: boolean; label: string; name: string; value: string; }>; valueSources: ValueSources | (operator: string) => ValueSources; }, operator: string) => boolean; defaultOperator: string; defaultValue: any; disabled: boolean; id: string; inputType: null | InputType; label: string; name: string; operators: FlexibleOptionList<{ [key: string]: unknown; disabled: boolean; label: string; name: string; value: string; }>; placeholder: string; validator: RuleValidator; value: string; valueEditorType: ValueEditorType | (operator: string) => ValueEditorType; values: FlexibleOptionList<{ [key: string]: unknown; disabled: boolean; label: string; name: string; value: string; }>; valueSources: ValueSources | (operator: string) => ValueSources; }
misc.fieldData.className?Classname
misc.fieldData.comparator?string | (f: { [key: string]: unknown; className: Classname; comparator: string | ((f: { [x: string]: unknown; label: string; disabled?: boolean | undefined; name: string; value: string; id?: string | undefined; operators?: FlexibleOptionList<{ [x: string]: unknown; value?: string | undefined; label: string; disabled?: boolean | undefined; name: string; }> | undefined; ... 9 more ...; cl...; defaultOperator: string; defaultValue: any; disabled: boolean; id: string; inputType: null | InputType; label: string; name: string; operators: FlexibleOptionList<{ [key: string]: unknown; disabled: boolean; label: string; name: string; value: string; }>; placeholder: string; validator: RuleValidator; value: string; valueEditorType: ValueEditorType | (operator: string) => ValueEditorType; values: FlexibleOptionList<{ [key: string]: unknown; disabled: boolean; label: string; name: string; value: string; }>; valueSources: ValueSources | (operator: string) => ValueSources; }, operator: string) => boolean
misc.fieldData.defaultOperator?string
misc.fieldData.defaultValue?any
misc.fieldData.disabled?boolean
misc.fieldData.id?string
misc.fieldData.inputType?null | InputType
misc.fieldData.labelstring
misc.fieldData.namestring
misc.fieldData.operators?FlexibleOptionList<{ [key: string]: unknown; disabled: boolean; label: string; name: string; value: string; }>
misc.fieldData.placeholder?string
misc.fieldData.validator?RuleValidator
misc.fieldData.valuestring
misc.fieldData.valueEditorType?ValueEditorType | (operator: string) => ValueEditorType
misc.fieldData.values?FlexibleOptionList<{ [key: string]: unknown; disabled: boolean; label: string; name: string; value: string; }>
misc.fieldData.valueSources?ValueSources | (operator: string) => ValueSources

Returns

null | FlexibleOptionList<FullOperator<string>>

Inherited from

FormatQueryOptions.getOperators


caution

API documentation is generated from the latest commit on the main branch. It may be somewhat inconsistent with official releases of React Query Builder.