Skip to content

About

Composable, dependency-free validation helpers.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

6 Commits

Folders and files

Repository files navigation

@sandsoftwaresolutions/validation

CI

Tiny, composable form and API-input validators with no runtime dependencies.

Install

npm install @sandsoftwaresolutions/validation

Works with import and require(), and ships TypeScript types for both.

Usage

import { email, minLength, required, validate } from "@sandsoftwaresolutions/validation";

const result = validate(form.password, [required, minLength(12)]);
if (!result.valid) showError(result.message);

validate(form.email, [required, email]);

API

  • required(value, message?) rejects null, undefined, and empty/whitespace-only strings.
  • email(value, message?) performs a lightweight email-address check.
  • minLength(minimum, message?) creates a string validator.
  • validate(value, validators) runs validators in order and returns the first failure.

Every result is either { valid: true } or { valid: false, message }, which makes it easy to use in forms and HTTP handlers. Validate and normalize security-sensitive input on the server as well.

About

Composable, dependency-free validation helpers.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages