Skip to main content

numerifyValues()

numerifyValues(rg: RuleGroupTypeAny, options: { concatOperator: string & {} | "||" | "+" | "CONCAT"; context: Record<string, any>; fallbackExpression: string; fieldIdentifierSeparator: string; fields: FlexibleOptionList<{ [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; }>; format: ExportFormat; 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: ...]: ...; disabled: ...; label: ...; name: ...; value: ...; }>; placeholder: string; validator: RuleValidator; value: string; valueEditorType: ValueEditorType | (operator: string) => ValueEditorType; values: FlexibleOptionList<{ [key: ...]: ...; disabled: ...; label: ...; name: ...; value: ...; }>; 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>>; numberedParams: boolean; operatorProcessor: RuleProcessor; paramPrefix: string; paramsKeepPrefix: boolean; parseNumbers: ParseNumbersPropConfig; placeholderFieldName: string; placeholderOperatorName: string; preserveValueOrder: boolean; preset: SQLPreset; quoteFieldNamesWith: string | [string, string]; quoteValuesWith: string; ruleProcessor: RuleProcessor; validator: QueryValidator; valueProcessor: ValueProcessorLegacy | ValueProcessorByRule; }): RuleGroupTypeAny

Defined in: packages/react-querybuilder/src/utils/formatQuery/utils.ts:96

Converts all string-type value properties of a query object into number where appropriate.

Used by formatQuery for the json* formats when parseNumbers is true.

Parameters

ParameterTypeDescription
rgRuleGroupTypeAny-
options{ concatOperator: string & {} | "||" | "+" | "CONCAT"; context: Record<string, any>; fallbackExpression: string; fieldIdentifierSeparator: string; fields: FlexibleOptionList<{ [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; }>; format: ExportFormat; 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: ...]: ...; disabled: ...; label: ...; name: ...; value: ...; }>; placeholder: string; validator: RuleValidator; value: string; valueEditorType: ValueEditorType | (operator: string) => ValueEditorType; values: FlexibleOptionList<{ [key: ...]: ...; disabled: ...; label: ...; name: ...; value: ...; }>; 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>>; numberedParams: boolean; operatorProcessor: RuleProcessor; paramPrefix: string; paramsKeepPrefix: boolean; parseNumbers: ParseNumbersPropConfig; placeholderFieldName: string; placeholderOperatorName: string; preserveValueOrder: boolean; preset: SQLPreset; quoteFieldNamesWith: string | [string, string]; quoteValuesWith: string; ruleProcessor: RuleProcessor; validator: QueryValidator; valueProcessor: ValueProcessorLegacy | ValueProcessorByRule; }-
options.concatOperator?string & {} | "||" | "+" | "CONCAT"Operator to use when concatenating wildcard characters and field names in "sql" format. The ANSI standard is `
options.context?Record<string, any>-
options.fallbackExpression?stringThis 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".
options.fieldIdentifierSeparator?stringWhen 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'"
options.fieldsFlexibleOptionList<{ [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; }>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.
options.format?ExportFormatThe ExportFormat.
options.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: ...]: ...; disabled: ...; label: ...; name: ...; value: ...; }>; placeholder: string; validator: RuleValidator; value: string; valueEditorType: ValueEditorType | (operator: string) => ValueEditorType; values: FlexibleOptionList<{ [key: ...]: ...; disabled: ...; label: ...; name: ...; value: ...; }>; 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>>-
options.numberedParams?booleanRenders 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
options.operatorProcessor?RuleProcessorThis 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.
options.paramPrefix?stringThis string will be placed in front of named parameters (aka bind variables) when using the "parameterized_named" export format. Default ":"
options.paramsKeepPrefix?booleanMaintains 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 (paramsKeepPrefixisfalse): // { firstName: "Stev" }
options.parseNumbers?ParseNumbersPropConfigRenders values as either number-types or unquoted strings, as appropriate and when possible. Each string-type value is evaluated against numericRegex to determine if it can be represented as a plain numeric value. If so, parseFloat is used to convert it to a number.
options.placeholderFieldName?stringAny rules where the field is equal to this value will be ignored. Default '~'
options.placeholderOperatorName?stringAny rules where the operator is equal to this value will be ignored. Default '~'
options.preserveValueOrder?booleanPreserves 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).
options.preset?SQLPresetOption presets to maximize compatibility with various SQL dialects.
options.quoteFieldNamesWith?string | [string, string]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'"
options.quoteValuesWith?stringCharacter to use for quoting string values in the SQL format. Default '
options.ruleProcessor?RuleProcessorThis function will be used to process each rule for query language formats. If not defined, the appropriate defaultRuleProcessor* for the format will be used.
options.validator?QueryValidatorValidator function for the entire query. Can be the same function passed as validator prop to QueryBuilder.
options.valueProcessor?ValueProcessorLegacy | ValueProcessorByRuleThis 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.

Returns

RuleGroupTypeAny


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.