Learn about our RFC process, Open RFC meetings & more.Join in the discussion! »

backbone-forms-validators

1.0.1 • Public • Published

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

Install

npm i backbone-forms-validators

DownloadsWeekly Downloads

2

Version

1.0.1

License

MIT

Unpacked Size

13.8 kB

Total Files

6

Last publish

Collaborators

  • avatar