Skip to main content
Home

Built and signed on GitHub Actions

It is unknown whether this package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers
It is unknown whether this package works with Cloudflare Workers
It is unknown whether this package works with Node.js
It is unknown whether this package works with Deno
It is unknown whether this package works with Bun
It is unknown whether this package works with Browsers
JSR Score
76%
Published
10 months ago (0.1.0)

@cndi/validators

This module is used to validate CNDI Template prompt responses.

# CNDI Template prompt specs can specify validators for prompts:
prompts:
  - type: Input
    name: lets_encrypt_email
    message: "Enter your email address for Let's Encrypt"
    validators:
      - email
      - min_length: 3

Each validator needs to be implemented in this module, otherwise the prompt will be assumed valid.

import { CNDIValidators } from "@cndi/validators";

const emailErrorMessage: string | null = CNDIValidators.email({
  value: "foo.bar",
  type: "Input",
});
console.log(emailErrorMessage); // 'Invalid email address'

const passwordErrorMessage: string | null = CNDIValidators.min_length({
  value: "foo",
  type: "Input",
  arg: 3,
});

// because the value has a length of atleast 3:
console.log(passwordErrorMessage); // null
Built and signed on
GitHub Actions

New Ticket: Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@cndi/validators

Import symbol

import * as validators from "@cndi/validators";
or

Import directly with a jsr specifier

import * as validators from "jsr:@cndi/validators";

Add Package

pnpm i jsr:@cndi/validators
or (using pnpm 10.8 or older)
pnpm dlx jsr add @cndi/validators

Import symbol

import * as validators from "@cndi/validators";

Add Package

yarn add jsr:@cndi/validators
or (using Yarn 4.8 or older)
yarn dlx jsr add @cndi/validators

Import symbol

import * as validators from "@cndi/validators";

Add Package

vlt install jsr:@cndi/validators

Import symbol

import * as validators from "@cndi/validators";

Add Package

npx jsr add @cndi/validators

Import symbol

import * as validators from "@cndi/validators";

Add Package

bunx jsr add @cndi/validators

Import symbol

import * as validators from "@cndi/validators";