UNPKG

@lucidcms/core

Version:

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

2 lines 1.09 kB
const e=(e,t)=>{if(e.type!==`range`||(e.min===void 0&&t.addIssue({code:`custom`,path:[`min`],message:`Range min is required`}),e.max===void 0&&t.addIssue({code:`custom`,path:[`max`],message:`Range max is required`}),e.step===void 0&&t.addIssue({code:`custom`,path:[`step`],message:`Range step is required`}),e.min===void 0||e.max===void 0||e.step===void 0))return;e.max<=e.min&&t.addIssue({code:`custom`,path:[`max`],message:`Range max must be greater than min`});let n=e.thumbs===2?2:1;if(!Array.isArray(e.default)||e.default.length!==n){t.addIssue({code:`custom`,path:[`default`],message:`Range default must contain ${n} value${n===1?``:`s`}`});return}for(let[n,r]of e.default.entries()){if(typeof r!=`number`||!Number.isFinite(r)||r<e.min||r>e.max){t.addIssue({code:`custom`,path:[`default`,n],message:`Range default values must be within min and max`});continue}let i=(r-e.min)/e.step;Math.abs(i-Math.round(i))>=1e-9&&t.addIssue({code:`custom`,path:[`default`,n],message:`Range default values must align to step`})}};export{e as validateRangeConfig}; //# sourceMappingURL=schema.mjs.map