Budibase is an open-source low-code platform for creating internal apps in minutes. Supports PostgreSQL, MySQL, MSSQL, MongoDB, Rest API, Docker, K8s 🚀
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

24 lines
767 B

import { flatten, map, isEmpty } from 'lodash/fp';
import { compileCode } from '@nx-js/compiler-util';
import {
isNonEmptyString,
executesWithoutException, $,
} from '../common';
import { applyRuleSet, makerule } from '../common/validationCommon';
const aggregateRules = [
makerule('name', 'choose a name for the aggregate',
a => isNonEmptyString(a.name)),
makerule('aggregatedValue', 'aggregatedValue does not compile',
a => isEmpty(a.aggregatedValue)
|| executesWithoutException(
() => compileCode(a.aggregatedValue),
)),
];
export const validateAggregate = aggregate => applyRuleSet(aggregateRules)(aggregate);
export const validateAllAggregates = all => $(all, [
map(validateAggregate),
flatten,
]);