Socket
Socket
Sign inDemoInstall

confere.js

Package Overview
Dependencies
0
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    confere.js

A simple promise based javascript validation library with extras


Version published
Weekly downloads
7
increased by600%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

confere.js Build Status

confere.js is a simple promise based javascript validation library heavily inspired by the laravel validation!

Installation

Download or clone the repo add lib/confere.js to your html script

Usage

var confere = new Confrere({
    rules: {
        name: 'required|min:3|max:254',
        email: 'required|email|max:254',
        birth_date: 'required|date|date_before:2004-01-01' //ex: under 13 not allowed
    }
});

confere.validate ({
    name: "Jhon Doe",
    email: "myemail@gmail.com",
    birth_date: "1992-05-12",
}).then (function () {
    //the data is valid, do some stuff ex: submiting the data    
}).catch(function (result) {
    //the data is invalid, show error messages, you can use the result.fields to retrive all validation errors errors    
});

With Forms

Html:

<form>
    <input type="text" name="name" data-rule="required|min:3"><br/>
    <input type="text" name="surname" data-rule="required|min:3"><br/>
    <input type="text" name="birth_date" data-rule="required|date|date_before:2004-01-01">
</form>
var confere = new Confere({
    rules: document.forms[0]
})
document.forms[0].addEventListener('submit', function (e) {
        e.preventDefault();
        confere.validate().then(function () {
            //the data is valid, do some stuff ex: submiting the data
        }).catch(function (err) {
            //the data is invalid, show error messages, you can use the result.fields to retrive all validation errors errors
        })
    });

The code above will produce the same output as the previous, but row there is no need for complicated configuration because we are using htm attributes the stuff that we all knows!

Contributing

Found a bug?
Open an Issue on github, if you fixed yourself, fork the repo, create a branch, commit your changes ad open a pull request.
Please be sure to not include unnecessary changes on your commit and add some test whenever is possible

Credits

Matt Kruse http://www.mattkruse.com/ - For his awesome js date functions found in JavascriptToolbox.com

Keywords

FAQs

Last updated on 03 Aug 2017

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc