Developer notes
- Import
createFormValidatorAddonfrom its addon subpath. - Pass an existing
validatorinstance to the addon. - The addon claims field and form rendering.
- The bridge does not destroy an externally owned instance.
Example 04 ยท Validator addon
The bridge normalizes a rejected payload, then the form-validator addon gives it to an existing validator-style instance instead of rendering a second error system.
Integration contract
This demo uses a small local stand-in for the optional peer's public instance methods. It does not bundle or imitate the full peer package.
Implementation
createFormValidatorAddon from its addon subpath.validator instance to the addon.Copy path
createFormValidatorAddon().<form id="invite-form" data-a11y-server-error-bridge>
<section data-validator-summary hidden tabindex="-1"></section>
<label for="invite-email">Email address</label>
<input id="invite-email" name="email" type="email">
<p id="invite-email-error" data-validator-error-for="email" hidden></p>
<button type="submit">Send invitation</button>
</form>import { createServerErrorBridge } from "../../dist/index.js";
import { createFormValidatorAddon } from
"../../dist/addons/form-validator.js";
import { createFormValidator } from "a11y-form-validator";
const form = document.querySelector("#invite-form");
const validator = createFormValidator(form);
const bridge = createServerErrorBridge(form, {
addons: [createFormValidatorAddon({
validator,
focusOnApply: true
})]
});