UNPKG

@adaptabletools/adaptable

Version:

Powerful data-agnostic HTML5 AG Grid extension which provides advanced, cutting-edge functionality to meet all DataGrid requirements

30 lines (29 loc) 1.5 kB
export const isAdaptableRuleValid = (abObject, api, context) => { if (abObject?.Rule?.Predicates?.length) { if (!api.predicateApi.isEveryPredicateValid(abObject?.Rule?.Predicates)) { return `The Predicate${abObject?.Rule?.Predicates?.length === 1 ? ' is' : 's are'} not valid`; } } if (abObject?.Rule?.BooleanExpression) { if (!api.expressionApi.isValidBooleanExpression(abObject?.Rule?.BooleanExpression, context.moduleInfo.ModuleName)) { return 'The Expression is not a valid Boolean Expression'; } } if (abObject?.Rule?.ObservableExpression) { if (!api.expressionApi.isValidObservableExpression(abObject?.Rule?.ObservableExpression, context.moduleInfo.ModuleName)) { return 'The Expression is not a valid Observable Expression'; } } if (abObject?.Rule?.AggregatedBooleanExpression) { if (!api.expressionApi.isValidAggregatedBooleanExpression(abObject?.Rule?.AggregatedBooleanExpression, context.moduleInfo.ModuleName)) { return 'The Expression is not a valid Aggregated Boolean Expression'; } } if (abObject?.Rule?.Predicates?.length) { const isAPredicateWithInvalidColumnId = abObject?.Rule?.Predicates?.some((predicate) => predicate.ColumnId !== undefined && predicate.ColumnId === ''); if (isAPredicateWithInvalidColumnId) { return 'Predicates with custom scope need a valid column'; } } return true; };