@lucidcms/core
Version:
The core of the Lucid CMS. It's responsible for spinning up the API and serving the CMS.
2 lines • 1.52 kB
JavaScript
import{copy as e}from"../../../../i18n/copy.mjs";import t from"../../../../../utils/helpers/deep-merge.mjs";import{checkboxFieldConfig as n}from"./config.mjs";import r from"../../utils/zod-safe-parse.mjs";import i from"../../custom-field.mjs";import a from"../../utils/key-to-title.mjs";import o from"../../../../formatters/index.mjs";import s from"zod";var c=class extends i{type=n.type;config;key;props;constructor(t,n){super(),this.key=t,this.props=n,this.config={key:this.key,type:this.type,details:{label:this.props?.details?.label??e(`admin:fields.${this.type}.${this.key}.label`,{defaultMessage:a(this.key)}),summary:this.props?.details?.summary,true:this.props?.details?.true,false:this.props?.details?.false},localized:this.props?.localized??!1,default:this.props?.default??!1,index:this.props?.index,ui:{hidden:this.props?.ui?.hidden,disabled:this.props?.ui?.disabled,condition:this.props?.ui?.condition,width:this.props?.ui?.width},validation:this.props?.validation}}get errors(){return t(super.errors,{required:{condition:e=>e==null||e===0,message:e(`server:core.fields.checkbox.validation.required`)}})}getSchemaDefinition(e){return{data:{columns:[{name:this.key,type:e.db.getDataType(`boolean`),nullable:!0,default:e.db.formatInsertValue(`boolean`,this.config.default)}]},error:void 0}}formatResponseValue(e){return o.formatBoolean(!!e)}uniqueValidation(e){let t=r(e,s.union([s.literal(1),s.literal(0),s.boolean()]));return t.valid?{valid:!0}:t}};export{c as default};
//# sourceMappingURL=custom-field.mjs.map