backbone-forms-validators
v1.0.1
Published
A set of Backbone-Forms validators
Downloads
14
Maintainers
Readme
Backbone-Forms validators
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'
}]
}
}
});
phone
Validates phone number
var form = new Backbone.Form({
schema: {
phone: {
type: 'Text',
validators: ['phone']
}
}
});
minlength
Validates length of entered text
var form = new Backbone.Form({
schema: {
text: {
type: 'Text',
validators: [{
type: 'minlength',
minlength: 3
}]
}
}
});
maxlength
Validates length of entered text
var form = new Backbone.Form({
schema: {
text: {
type: 'Text',
validators: [{
type: 'maxlength',
maxlength: 9
}]
}
}
});
Validators PL
nip
Validates NIP (Polish tax identification number)
var form = new Backbone.Form({
schema: {
nip: {
type: 'Text',
validators: ['nip']
}
}
});
pesel
Validates Pesel (Polish identification number)
var form = new Backbone.Form({
schema: {
pesel: {
type: 'Text',
validators: ['pesel']
}
}
});
regon
Validates REGON (Polish Taxpayer Identification Number)
var form = new Backbone.Form({
schema: {
regon: {
type: 'Text',
validators: ['regon']
}
}
});