
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
cruddy-forms
Advanced tools
Cruddy Forms is a TypeScript library for generating HTML forms with built-in validation using TypeBox. It provides a simple and type-safe way to create forms, validate user input, and handle form submissions.
Install Cruddy Forms using npm:
npm install cruddy-forms
Or using yarn:
yarn add cruddy-forms
Or using pnpm:
pnpm add cruddy-forms
Add CruddyForms to your project
Install the CruddyForms package into your project, using pnpm, yarn, or npm.
Define the schema for your form using TypeBox
In your typescript server code, use the TypeBox module to set the constraints you want to enforce for each field in your form, such as minLength or maxLength. Use regular expressions for more complex constraints.
Use CruddyForms to create the HTML for your form
In your typescript server code, use the CruddyForms module to convert your TypeBox schema into an HTML form with built-in client-side validation. Serve the form to clients, along with the Normform CSS file.
Use CruddyForms for server-side validation
In your typescript server code, use the CruddyForms module to validate form submissions, in case a user bypasses client-side validation.
Add custom server-side validation (Optional)
If you need additional server-side validation, e.g. making sure a username is unique, create a REST endpoint and tell CruddyForms about it. CruddyForms will add the endpoint data to the HTML form it generates, for use by cruddy-client.js. Serve cruddy-client.js along with the generated form, so that it will call your endpoint and display relevant error messages.
Here's a simple example of how to use Cruddy Forms:
import { Type } from "@sinclair/typebox";
import { Form, FormInputText } from "cruddy-forms";
// Define your form schema
const schema = Type.Object({
username: Type.String({
element: "input",
inputType: "text",
minLength: 3,
maxLength: 20,
} as FormInputText),
password: Type.String({
element: "input",
inputType: "password",
minLength: 8,
} as FormInputText),
});
// Create a form instance
const form = new Form(schema);
// Generate HTML
const html = form.getHTML();
// Validate form data
const formData = new FormData(/* ... */);
const validationResult = form.validate(formData);
if (validationResult.valid) {
console.log("Form is valid:", validationResult.data);
} else {
console.log("Validation errors:", validationResult.errors);
}
Form<T extends TObject>The main class for creating and managing forms.
constructor(schema: T, buttonLabel?: string, options?: CruddyFormOptions)
schema: A TypeBox schema defining the form structurebuttonLabel: (Optional) Label for the submit buttonoptions: (Optional) Configuration options for the formgetHTML(values?: Partial<Static<T>>, lang?: string): string
Generate HTML for the formgetHTMLComponent(values?: Partial<Static<T>>, lang?: string): string
Generate HTML for the form wrapped in a custom elementvalidate(formData: FormData, errorHeading?: string): ValidationResult
Validate form datavalidateObject(obj: object, errorHeading?: string): ValidationResult
Validate an object against the form schemaHTMLBuilder<T extends TObject>A utility class for building HTML elements based on a TypeBox schema.
Validator<T extends TObject>A utility class for validating form data against a TypeBox schema.
Contributions to Cruddy Forms are welcome! Please follow these steps to contribute:
Please ensure your code follows the existing style and includes appropriate tests.
Cruddy Forms is released under the MIT License. See the LICENSE file for details.
FAQs
HTML form generator using typebox and normform
We found that cruddy-forms demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.