I am using react-querybuilder. field validation is not working. See this StackBlitz when you click on Rule and check all field there is no error on that.
export const fields = (
{
name: 'lastName',
label: 'Last Name',
placeholder: 'Enter last name',
validator: (r: RuleType) => !!r.value,
},
{
name: 'view',
label: 'Unique views',
inputType: 'number',
operators: [
{ name: '=', label: '=' },
{ name: '<', label: 'less than' },
{ name: '>', label: 'more than' },
{ name: 'between', label: 'in between' },
],
validator: (r: RuleType) => r.value > 0,
},
] satisfies Field[]
).map(toFullOption);
This is my QueryBuilder component
import 'react-querybuilder/dist/query-builder.scss'
import './styles.scss'
import { QueryBuilderAntD } from '@react-querybuilder/antd'
import { useState } from 'react'
import type { RuleGroupType } from 'react-querybuilder'
import { QueryBuilder, defaultValidator, formatQuery } from 'react-querybuilder'
import { fields } from './fields'
const initialQuery: RuleGroupType = { combinator: 'and', rules: [] };
export const SegmentGroupQueryBuilder = () => {
const [query, setQuery] = useState(initialQuery);
console.log(query)
return (
<>
<QueryBuilderAntD>
<QueryBuilder
fields={fields}
query={query}
onQueryChange={setQuery}
validator={defaultValidator}
controlClassnames={{ queryBuilder: 'queryBuilder-branches' }}
/>
</QueryBuilderAntD>
<pre>{formatQuery(query, {
format: 'sql'
})
}</pre>
</>
);
}
I am using antd/querybuilder packages: 7.2.0. However, it is working here don't know what is issue. I tried in different project as well. What could be the possible issue? Its not showing any error on UI or color, even rendered input html is not having invalid error class as mentioned in docs.
