UNPKG

@lucidcms/core

Version:

The core of the Lucid CMS. It's responsible for spinning up the API and serving the CMS.

2 lines 999 B
import e from"../../../utils/errors/lucid-error.mjs";import{translate as t}from"../../i18n/translate.mjs";const n=e=>e.config.ui?.condition,r=(e,t)=>{let n=[],r=t.treeParent;for(;r!==null;)n.push(r),r=e.get(r)?.treeParent??null;return n.push(null),n},i=(i,a,o)=>{for(let[s,c]of o.fields){let l=n(c);if(l)for(let n of l.groups??[])for(let l of n){let n={field:s,target:l.field,type:i,typeKey:a};if(l.field===s)throw new e({message:t(`server:core.fields.condition.target.self`,{data:n})});let u=o.fields.get(l.field);if(!u)throw new e({message:t(`server:core.fields.condition.target.not.found`,{data:n})});if(u.type===`repeater`||u.type===`tab`||u.type===`section`||u.type===`collapsible`)throw new e({message:t(`server:core.fields.condition.target.invalid.type`,{data:{...n,targetType:u.type}})});if(!r(o.fields,c).includes(u.treeParent))throw new e({message:t(`server:core.fields.condition.target.out.of.scope`,{data:n})})}}};export{i as default}; //# sourceMappingURL=check-field-conditions.mjs.map