npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

v4f

v0.1.2

Published

A declarative, efficient, and flexible JavaScript validation library for Humans .

Downloads

24

Readme

Documentation | Exemples | API Reference | Need help ?

Description :

V4F

A javascript library for validation that encourages rapid development and clean code, unlike other validation libraries v4f is designed from the ground up to be adaptable for any context, and it takes care of all your validation in different environments (client, server, native).

You can use V4f together with (react.js, angular.js, vue.js, jquery) or with any web framework.

Why !

why new validation library where they exist several good ones around, sure you are completely right. but the problem with those libraries is that almost all of the theme focus in data validation and they forget the key reason why we do validation for, is that we desire to guide our users by showing them what they missing or what they doing wrong with some pieces of information, but sadly you end up with generic messages errors or writing code on the top of this libraries every time you use them.

V4F comes to solve this problem by focusing on those two features validations and failures messages, V4F comes with easy and powerful syntax that feels more human that everyone can understand with more than 40+ built-in rules.

Out of the box

Schema : v4f use the concept of the schema types to indicate your rules that will be checked later were we need it, this notion is powerful it lets you create complex rules ones and use it multiple types.

Nested Schema : with v4f you can use a schema that already created inside other schemas to create complex validation.

Related Field : validate fields that related or depends on each other easily with a simple syntax.

One-field : Validate only one field from schema very useful in situations like instead field validation feedback.

Getting started

Syntax overview

import { Schema, Field } from "v4f";

const User = Schema({
 username: Field()
  .string()
  .alphaNum()
  .required(),
 email: Field()
  .string()
  .email()
  .required(),
 password: Field()
  .string()
  .min(6)
  .max(20)
  .not.equals(["#username"])
  .not.equals(["#email"])
  .required(),
 cPassword: Field()
  .string()
  .equals(["#password"])
  .required()
});

const result = User.validate(data);

The above schema defines the following constraints:

  • username :
    • Must be string
    • Must be alpha numeric
    • Required
  • email :
    • Must be string
    • Must be valid email
    • Required
  • password :
    • Must be string
    • At least 6 characters long but no more than 20
    • Must not be equals to username and email
    • Required
  • cPassword :
    • Must be string
    • Must equals to password
    • Required

Instalation

To install the stable version:

$ npm install v4f

This assumes you are using npm as your package manager.

or

$ yarn add v4f

If you you use yarn as package your package manager.

Usage

Commonjs

var v4f = required("v4f");

const User = v4f.Schema({// Your schema here});

ES6

import {Schema, Field} from "v4f";

const User = Schema({// Your schema here});

Read the Usage Guide on our website for detailed instructions on how to use the library.

Contributing

In general, we follow the "fork-and-pull" Git workflow.

  1. Fork on GitHub
  2. Make changes to your own fork
  3. Submit a Pull request so that we can review your changes

Test

$ yarn test

Linter

$ yarn lint

Maintainers

  • reyx7 - Nassih Soufiane (author)

License (MIT)

MIT License

Copyright (c) 2019 soufiane nassih [email protected]

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.