Skip to content

polyseam/cndi-validators

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@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

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published