0.2.7 • Published 8 years ago

checkit-money v0.2.7

Weekly downloads
3
License
MIT
Repository
github
Last release
8 years ago

checkit-money

A money / currency validator for checkit

Installation

npm install --save checkit-money

Usage (ES6)

import money from 'checkit-money';
import Checkit from 'checkit';
Checkit.Validator.prototype.money = money;

const checkit = new Checkit({
  foo: ['money']
});

const test = {
  foo: 23.45
};

checkit.run(test).then(() => {
  console.log('validated');
}).catch(Checkit.Error, function(err) {
  console.log(err.toJSON());
});

By default a number with an optional 2 decimal palces is accepted. Strings and numbers are valid:

34
4.56
0.34
'65.34'

Optional paramaters

To ensure that the vaule always has a decimal value:

const checkit = new Checkit({
  foo: ['money:true']
});

To allow the value to have an optional preceding symbol. EG '£34.56'

const checkit = new Checkit({
  foo: ['money:false:true']
});
0.2.7

8 years ago

0.2.6

8 years ago

0.2.5

8 years ago

0.2.4

8 years ago

0.2.3

8 years ago

0.2.2

8 years ago

0.2.1

8 years ago

0.2.0

8 years ago

0.1.0

8 years ago