Validation
Modes and schema adapters — you choose when fields validate.
@jayoncode/form-intelligence
Declare the workflow. Keep the markup. Submit with confidence.
Headless form engine — validation, when() rules, drafts, wizards, and safe submit in one createForm(). Your UI binds to state; the library owns the workflow.
import { createForm, when } from "@jayoncode/form-intelligence";
// Pain: enterprise fields, autosave, and submit guards
// usually mean 4 effects and a race on every keystroke.
createForm({
target: "#checkout",
schema: {
plan: { required: true },
seatCount: { required: true },
companyName: { minLength: 2 },
email: "email",
},
rules: [
when("plan")
.equals("enterprise")
.show("seatCount", "companyName")
.require("seatCount", "companyName"),
],
workflow: {
autosave: {
enabled: true,
debounceMs: 800,
onSave: (values) => api.saveDraft(values),
},
draft: {
enabled: true,
storageKey: "checkout:draft",
},
},
// Same store as form.subscribe() — fires once after create, then on every notify
subscribe: (form) => {
syncCheckoutChrome(form.state); // draft badge, plan label, …
},
async onSubmit(values) {
await api.checkout(values); // isSubmitting + double-submit guard built in
},
});Modes and schema adapters — you choose when fields validate.
Show / hide / require without scattered useEffect copies.
Survive refresh; debounce saves you own.
Built-in submitting state, duplicate-submit guard, cancel, and optional offline queue — not a payment SDK.
Enhance a normal <form>, or bind() into React / Vue / your own inputs — same engine, not a form builder.