import isObject from 'lodash/isObject' import isString from 'lodash/isString' import type {FieldProps, ConditionsType} from '../types' export const getConditions = (conditions?: ConditionsType | string) => { if (isString(conditions)) return [[conditions], []] if (isObject(conditions)) { const values: any[] = [] // TODO: Make this better const keys = Object.keys(conditions) .map((key) => { const value = conditions[key] as FieldProps[] if (!value) return false if (value.filter(Boolean)) { values.push(value) } return key }) .filter(Boolean) return [keys, values] } // eslint-disable-next-line no-console console.log('Your conditions should be objects or strings. Received:', conditions) return [[], []] }