Technical Documentation

Validation Registry (@dfbe/core/registry)

The @dfbe/core/registry entry point provides builder metadata — static data structures describing what validation rules are available for each field type. This is designed for use in admin tools (like the Studio's Property Panel) rather than in production forms.

1. VALIDATION_REGISTRY

The central registry mapping each ValidationCategory to its human-readable label and list of configurable rules.

import { VALIDATION_REGISTRY } from "@dfbe/core/registry";

Structure

VALIDATION_REGISTRY: Record< ValidationCategory, { label: string; rules: ValidationRuleDefinition[] } >;

ValidationCategory values

CategoryDescriptionApplied to field types
stringText-based inputtext, textarea, email
numberNumeric inputnumber
arrayMulti-selectcheckbox-group
booleanSingle checkboxcheckbox
dateDate pickerdate
selectionSingle-select (no extra rules)select, combobox, searchable-select, radio
fileFile uploadfile

ValidationRuleDefinition shape

Each entry in rules has the following properties:

PropertyTypeDescription
keystringThe property name in the JSON schema (e.g. "minLength").
labelstringHuman-readable label for the UI editor (e.g. "Minimum Length").
inputType"number" | "text" | "boolean" | "select"What kind of input to render in the Property Panel.
defaultMessagestringDefault error message template. Use {val} as placeholder for the rule value.
descriptionstringOptional tooltip text for the editor.
optionsstring[]Options list, only used when inputType is "select".

Example: Building a Property Panel

import { VALIDATION_REGISTRY, FIELD_TYPE_CATEGORY_MAP } from "@dfbe/core/registry"; import type { FieldType } from "@dfbe/core"; function ValidationEditor({ fieldType }: { fieldType: FieldType }) { const category = FIELD_TYPE_CATEGORY_MAP[fieldType]; if (!category) return null; // e.g. markdown fields have no validation const { label, rules } = VALIDATION_REGISTRY[category]; return ( <section> <h4>{label}</h4> {rules.map((rule) => ( <div key={rule.key}> <label title={rule.description}>{rule.label}</label> {rule.inputType === "boolean" && <input type="checkbox" />} {rule.inputType === "number" && <input type="number" />} {rule.inputType === "text" && <input type="text" />} </div> ))} </section> ); }

2. FIELD_TYPE_CATEGORY_MAP

Maps every FieldType to its corresponding ValidationCategory (or null for types with no validation).

import { FIELD_TYPE_CATEGORY_MAP } from "@dfbe/core/registry";

Full Mapping

Field TypeValidation Category
textstring
textareastring
emailstring
numbernumber
selectselection
comboboxselection
searchable-selectselection
radioselection
checkboxboolean
checkbox-grouparray
datedate
filefile
markdownnull (no validation)

Usage

const category = FIELD_TYPE_CATEGORY_MAP["number"]; // "number" const rules = VALIDATION_REGISTRY["number"].rules; // [{ key: "min", ... }, { key: "max", ... }, { key: "multipleOf", ... }, ...]

3. Available Rules Per Category

string Rules (for text, textarea, email)

KeyInput TypeDefault Message
minLengthnumberMinimal {val} karakter
maxLengthnumberMaksimal {val} karakter
regextextFormat tidak valid
emailbooleanFormat email tidak valid
startsWithtextHarus diawali dengan {val}
endsWithtextHarus diakhiri dengan {val}
includestextHarus mengandung {val}
ignoreCaseboolean(modifier — no error message)

number Rules

KeyInput TypeDefault Message
minnumberMinimal bernilai {val}
maxnumberMaksimal bernilai {val}
minLengthnumberMinimal terdiri dari {val} digit
maxLengthnumberMaksimal terdiri dari {val} digit
multipleOfnumberHarus kelipatan {val}
startsWithtextHarus diawali dengan {val}
endsWithtextHarus diakhiri dengan {val}
includestextHarus mengandung {val}

array Rules (for checkbox-group)

KeyInput TypeDefault Message
minItemsnumberPilih setidaknya {val} opsi
maxItemsnumberPilih maksimal {val} opsi
requireAllCheckedbooleanHarap centang semua opsi

date Rules

KeyInput TypeDefault Message
minDatetextTanggal minimal adalah {val}
maxDatetextTanggal maksimal adalah {val}

boolean Rules (for checkbox)

No extra rules. Only required applies — enforces that the checkbox must be checked.

selection Rules (for select, combobox, searchable-select, radio)

No extra rules. Only required applies — enforces that a value must be selected.

file Rules

KeyInput TypeDefault Message
maxFileSizenumberUkuran file tidak boleh melebihi {val} MB
accepttextFormat file tidak diizinkan. Harus berupa: {val}

4. Design Notes

  • This module is intentionally separate from the main engine bundle (@dfbe/core). It is never imported by FormEngineProvider or FieldRenderer, keeping the production runtime lean.
  • The registry is static and does not change at runtime. It is safe to call at module initialization time.
  • ignoreCase is a modifier that affects how startsWith, endsWith, and includes are evaluated — it does not produce its own error message.