### Defining a Select Form Field in Easypanel Builder Schema Source: https://github.com/easypanel-io/builders/blob/main/README.md This snippet provides an example of defining a 'select' type form field within an Easypanel builder's schema. It uses `oneOf` to specify a list of predefined options, each with an `enum` value and a display `title`. ```TypeScript { // ... selectField: { type: "string", title: "Select Field", oneOf: [ { enum: ["first"], title: "First Option" }, { enum: ["second"], title: "Second Option" }, { enum: ["third"], title: "Third Option" } ] } } ``` -------------------------------- ### Defining a Next.js Builder in Easypanel Source: https://github.com/easypanel-io/builders/blob/main/README.md This snippet demonstrates how to define a new builder for Easypanel using `createBuilder`. It includes a schema for user input (package manager, telemetry) and a `generate` function to produce Dockerfile content based on the input. The `as const` assertion is crucial for type inference. ```TypeScript import { createBuilder, joinLines } from "~builders-utils"; export default createBuilder({ name: "Next.js", schema: { type: "object", required: ["packageManager", "disableTelemetry"], properties: { packageManager: { type: "string", title: "Package Manager", oneOf: [ { enum: ["npm"], title: "NPM" }, { enum: ["yarn"], title: "Yarn" } ], default: "npm" }, disableTelemetry: { type: "boolean", title: "Disable Telemetry", default: false } } } as const, generate({ packageManager, disableTelemetry }) { const dockerfileContent = joinLines([ "// ...", "EXPOSE 3000", "ENV PORT 3000", "CMD [\"node\", \"server.js\"]" ]); return [{ name: "Dockerfile", content: dockerfileContent }]; } }); ``` -------------------------------- ### Transforming Error Messages in Easypanel Builders Source: https://github.com/easypanel-io/builders/blob/main/README.md This snippet illustrates how to use the `transformErrors` function in an Easypanel builder. It allows modifying default error messages based on their `name` (e.g., 'pattern' errors), providing more user-friendly feedback. ```TypeScript { // ... transformErrors(errors) { return errors.map((error) => { if (error.name === "pattern") { error.message = "Only digits are allowed"; } return error; }); } } ``` -------------------------------- ### Implementing Custom Validation Rules for Easypanel Builders Source: https://github.com/easypanel-io/builders/blob/main/README.md This snippet shows how to add a custom `validate` function to an Easypanel builder. It receives `formData` and an `errors` object, allowing for custom validation logic, such as checking if two password fields match, and adding specific error messages. ```TypeScript { // ... validate(formData, errors) { if (formData.pass1 !== formData.pass2) { errors.pass2.addError("Passwords don't match"); } return errors; } } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.