Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

n4s

Package Overview
Dependencies
Maintainers
1
Versions
165
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

n4s

Assertion library for form validations

  • 5.0.28
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
18K
decreased by-29.93%
Maintainers
1
Weekly downloads
 
Created
Source

Enforce - n4s

Join Discord Version Downloads bundlephobia Status

Enforce is a validations assertions library. It provides rules that you can test your data against.

By default, enforce throws an error when your validations fail. These errors should be caught by a validation testing framework such as Vest.

You can extend Enforce per need, and you can add your custom validation rules in your app.

import { enforce } from 'n4s';

enforce(4).isNumber();
// passes

enforce(4).isNumber().greaterThan(2);
// passes

enforce(4)
  .lessThan(2) // throws an error, will not carry on to the next rule
  .greaterThan(3);

Installation

npm i n4s

Non throwing validations

This functionality replaces the no-longer supported ensure export, as it performs the same functionality with better performance.

If you wish to use enforce's functionality safely with a boolean return interface, you can use its lazy validation interface:

enforce.isArray().longerThan(3).test([1, 2, 3]);

Read the docs

Keywords

FAQs

Package last updated on 25 Nov 2024

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc