EDlabsEDcheck

One field

Validate one field when the user leaves the input, without sending the whole form.

You do not always want to wait for submit. Sometimes, when the person leaves the input (onBlur), you already want to know if that name looks real.

bound.node("fullName") gives you a handle for that field only. It uses the same rules and context as the whole object, trimmed to that path.

onBlur example

const FullName = UserSemantic.node("fullName"); async function onBlur(value: string) {  const controller = new AbortController();  const result = await FullName.safeParse(value, {    signal: controller.signal,  });   return result;}

The handle is memoized. Calling node("fullName") many times returns the same object.

Cancel the previous request

If the person keeps typing, abort the previous AbortController. If you do not, an old answer can arrive after a newer one.

let controller = new AbortController(); async function onChange(value: string) {  controller.abort();  controller = new AbortController();   try {    return await FullName.safeParse(value, { signal: controller.signal });  } catch (error) {    if (error instanceof EDcheckAbortError) {      return null;    }    throw error;  }}

EDcheck does not cancel old requests by itself. You must pass the signal. And a shared server must not abort another request’s work.

What about multi-field rules?

A crossField rule only runs on a node if every path sits under that node. If the rule looks at age and occupation, validating only age will not fire it.

Check node.ruleIds to see which rules that field covers. Leave the rest for the whole-object submit.

FullName.ruleIds;// for example: ["fullName"]