All Projects → imbrn → V8n

imbrn / V8n

Licence: mit
☑️ JavaScript fluent validation library

Programming Languages

javascript
184084 projects - #8 most used programming language
typescript
32286 projects
shell
77523 projects

Projects that are alternatives of or similar to V8n

Lcformvalidation
Javascript based form validation library, third party library / framework agnostic.
Stars: ✭ 58 (-98.5%)
Mutual labels:  validation, library
Restless
Express.js api, type safe validations and more
Stars: ✭ 32 (-99.17%)
Mutual labels:  validation, library
Bunny
BunnyJS - Lightweight native (vanilla) JavaScript (JS) and ECMAScript 6 (ES6) browser library, package of small stand-alone components without dependencies: FormData, upload, image preview, HTML5 validation, Autocomplete, Dropdown, Calendar, Datepicker, Ajax, Datatable, Pagination, URL, Template engine, Element positioning, smooth scrolling, routing, inversion of control and more. Simple syntax and architecture. Next generation jQuery and front-end framework. Documentation and examples available.
Stars: ✭ 473 (-87.74%)
Mutual labels:  validation, library
Svelte Forms Lib
📝. A lightweight library for managing forms in Svelte
Stars: ✭ 238 (-93.83%)
Mutual labels:  validation, library
Validatetor
Android library for fast and simple string validation
Stars: ✭ 136 (-96.47%)
Mutual labels:  validation, library
Inapppy
Python In-app purchase validator for Apple AppStore and GooglePlay.
Stars: ✭ 110 (-97.15%)
Mutual labels:  validation, library
Accord
Accord: A sane validation library for Scala
Stars: ✭ 519 (-86.55%)
Mutual labels:  validation, library
Ratifier
Ratifier is a form validation library for Android.
Stars: ✭ 123 (-96.81%)
Mutual labels:  validation, library
Php Validate
Lightweight and feature-rich PHP validation and filtering library. Support scene grouping, pre-filtering, array checking, custom validators, custom messages. 轻量且功能丰富的PHP验证、过滤库。支持场景分组,前置过滤,数组检查,自定义验证器,自定义消息。
Stars: ✭ 225 (-94.17%)
Mutual labels:  validation, library
Easyvalidation
✔️ A text and input validation library in Kotlin for Android
Stars: ✭ 328 (-91.5%)
Mutual labels:  validation, library
React Hook Form
📋 React Hooks for form state management and validation (Web + React Native)
Stars: ✭ 24,831 (+543.62%)
Mutual labels:  validation
Cordova Plugman
Apache Cordova Plugman
Stars: ✭ 379 (-90.18%)
Mutual labels:  library
Kooper
Kooper is a simple Go library to create Kubernetes operators and controllers.
Stars: ✭ 388 (-89.94%)
Mutual labels:  library
Vugu
Vugu: A modern UI library for Go+WebAssembly (experimental)
Stars: ✭ 4,251 (+10.19%)
Mutual labels:  library
Android Customtabs
Chrome CustomTabs for Android demystified. Simplifies development and provides higher level classes including fallback in case Chrome isn't available on device.
Stars: ✭ 378 (-90.2%)
Mutual labels:  library
Linux Steam Integration
Helper for enabling better Steam integration on Linux
Stars: ✭ 386 (-89.99%)
Mutual labels:  library
Lager
C++ library for value-oriented design using the unidirectional data-flow architecture — Redux for C++
Stars: ✭ 379 (-90.18%)
Mutual labels:  library
Theglowingloader
TheGlowingLoader is the highly configurable library to indicate progress and is natively created for Android Platform. It is an implementation of a design composed by Shashank Sahay.
Stars: ✭ 379 (-90.18%)
Mutual labels:  library
Validate
⚔ Go package for data validation and filtering. support Map, Struct, Form data. Go通用的数据验证与过滤库,使用简单,内置大部分常用验证、过滤器,支持自定义验证器、自定义消息、字段翻译。
Stars: ✭ 378 (-90.2%)
Mutual labels:  validation
Fire Hpp
Fire for C++: Create fully functional CLIs using function signatures
Stars: ✭ 395 (-89.76%)
Mutual labels:  library

v8n

The ultimate JavaScript validation library you've ever needed.
Dead simple fluent API. Customizable. Reusable.

CircleCI npm version npm bundle size (minified + gzip)

Installation - Documentation - API

Buy Me A Coffee

Introducing v8n

v8n is an acronym for validation. Notice that it has exactly eight letters between v and n in the "validation" word. This is the same pattern we are used to seeing with i18n, a11y, l10n ...

Chainable API

Create validations very easily with its chainable API:

v8n()
  .string()
  .minLength(5)
  .first("H")
  .last("o")
  .test("Hello"); // true

Incredibly fluent

Mix rules and modifiers together to create complex validations with great ease and fluency:

v8n()
  .array()
  .every.number()
  .not.some.negative()
  .test([1, 2, -3]); // false - no negative please!

So fluent that it looks like English:

v8n()
  .some.not.uppercase() // expects that some character is not uppercase
  .test("Hello"); // true

v8n()
  .not.some.uppercase() // expects that no character is uppercase
  .test("Hello"); // false

Notice how we made very different validation strategies just by changing the order of the modifiers. It's so intuitive that seems to be impossible, but this is v8n.

Customizable

Create your own custom validation rules in a very intuitive way:

function foo() {
  return value => value === "bar";
}

v8n.extend({ foo });

v8n will treat them like built-in ones:

v8n()
  .string()
  .foo()
  .test("bar"); // true

Reusable

Export validations just like you're used to do with your JavaScript modules:

specialNumber.js

import v8n from "v8n";

export default v8n()
  .number()
  .between(50, 100)
  .not.even();

and use them anywhere you want:

import specialNumber from "../specialNumber";

specialNumber.test(63); // true

For any kind of data

Use v8n to validate your data regardless of its type. You can validate primitives, arrays, objects and whatever you want! You can also use them together!

// numbers
v8n()
  .number()
  .between(5, 10)
  .test(7); //true

// strings
v8n()
  .string()
  .minLength(3)
  .test("foo"); // true

// arrays
v8n()
  .array()
  .every.even()
  .test([2, 4, 6]); // true

// objects
const myData = { id: "fe03" };

v8n()
  .schema({
    id: v8n().string()
  })
  .test(myData); // true

For any kind of validation

Do simple validations with boolean based tests. Get more information about your validation process with exception based tests. And of course, perform asynchronous tests as well. All in one library.

Boolean based validation:

v8n()
  .string()
  .first("H")
  .test("Hello"); // true

Exception based validation:

try {
  v8n()
    .string()
    .first("b")
    .check("foo");
} catch (ex) {
  console.log(ex.rule.name); // first
}

Getting all failures:

const failed = v8n()
  .string()
  .minLength(3)
  .testAll(10);

failed;
// [
//   ValidationError { rule: { name: "string", ... } },
//   ValidationError { rule: { name: "minLength", ... } }
// ]

Async validation:

If your validation strategy has some rule that performs time consuming validation, like a back-end check, you should use asynchronous validation:

v8n()
  .somAsyncRule()
  .testAsync("foo") // returns a Promise
  .then(result => {
    /* valid! */
  })
  .catch(ex => {
    /* invalid! */
  });

Shareable

Share your rules with the world, and use theirs as well.

Create useful validation rules and share them with the open source community, and let people around the world validate without reinventing the wheel.

Ready to use!

There are a lot of built-in rules and modifiers for you to use already implemented in v8n's core. Take a look at all of them in our API page. But if you can't find what you need, go ahead and make it.

Tiny!

All these incredible features for just a few bytes:

npm bundle size (minified + gzip)

Architecture

The v8n core is composed of rules and modifiers. They are used together to build complex validations in an easy way.

Rules

Rules are the heart of the v8n ecosystem. You use them to build your validation strategies:

v8n()
  .string()
  .minLength(3)
  .test("Hello"); // true

In this code snippet, we're using two rules (string and minLength) to build our validation strategy. So our validated value ("Hello") is valid because it's a string and it is at least 3 characters long.

Rules can be more powerful if used along with modifiers. Learn about them in the next section.

Modifiers

Modifiers can be used to change rules meaning. For example, you can use the not modifier to expect the reversed result from a rule:

v8n()
  .not.equal(5)
  .test(5); // false

You can check all available modifiers on our documentation page.

Modifiers are very powerful. They work as decorators for rules. When used together, they allow you to build very complex validations.

Contribute

Contributions of any kind are welcome! Read our CONTRIBUTING guide.

License

MIT License

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].