GithubHelp home page GithubHelp logo

tomi77 / backbone-forms-validators Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 59 KB

A set of Backbone-Forms validators

Home Page: https://tomi77.github.io/backbone-forms-validators/index.html

License: MIT License

CoffeeScript 54.81% JavaScript 22.79% HTML 22.40%
backbone-forms validators validation email-validation phone-validation nip-validation pesel-validation regon-validation

backbone-forms-validators's Introduction

Backbone-Forms validators

Build Status Coverage Status Code Climate devDependencies Status peerDependency Status Downloads

A set of Backbone-Forms validators

Table of contents

Installation

bower install backbone-forms-validators

or

npm install backbone-forms-validators

Usage

RequireJS

Add packages to config file:

packages: [{
  name: 'backbone-forms-validators',
  location: 'bower_components/backbone-forms-validators',
  main: 'bbf-validators'
}]

Use:

define['backbone-forms-validators', 'backbone-forms-validators/pl'], function() {
  // Your code
}

Vanilla JS

<script type="text/javascript" src="bower_components/backbone-forms-validators/bbf-validators.js"></script>
<script type="text/javascript" src="bower_components/backbone-forms-validators/pl.js"></script>

<!-- Rest od code -->

Webpack

require('backbone-forms-validators')
require('backbone-forms-validators/pl')

// Rest of code

Validators

multiple

var form = new Backbone.Form({
  schema: {
    emails: {
      type: 'Text',
      validators: [{
        type: 'multiple',
        base_type: 'email',
        separator: ',',
        message: 'Emails separated by colon'
      }]
    }
  }
});

Demo

phone

Validates phone number

var form = new Backbone.Form({
  schema: {
    phone: {
      type: 'Text',
      validators: ['phone']
    }
  }
});

Demo

minlength

Validates length of entered text

var form = new Backbone.Form({
  schema: {
    text: {
      type: 'Text',
      validators: [{
        type: 'minlength',
        minlength: 3
      }]
    }
  }
});

Demo

maxlength

Validates length of entered text

var form = new Backbone.Form({
  schema: {
    text: {
      type: 'Text',
      validators: [{
        type: 'maxlength',
        maxlength: 9
      }]
    }
  }
});

Demo

Validators PL

nip

Validates NIP (Polish tax identification number)

var form = new Backbone.Form({
  schema: {
    nip: {
      type: 'Text',
      validators: ['nip']
    }
  }
});

Demo

pesel

Validates Pesel (Polish identification number)

var form = new Backbone.Form({
  schema: {
    pesel: {
      type: 'Text',
      validators: ['pesel']
    }
  }
});

Demo

regon

Validates REGON (Polish Taxpayer Identification Number)

var form = new Backbone.Form({
  schema: {
    regon: {
      type: 'Text',
      validators: ['regon']
    }
  }
});

Demo

backbone-forms-validators's People

Contributors

tomi77 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.