Asynchronous input filter
A high-level library for filtering (sanitization) and validating input data
Installation
npm install input-filter-async
Usage
Basic usage
NOTE:
- if
required: true
is NOT specified, value is considered optional - value is pre filtered regardless whether it's mandatory or optional, if value is not given
null
is placed instead - if value is optional but given then it's validated
- finally if value passed validation then it's post filtered
Basic validation and sanitization is build upon node-validator library by Chris O'Hara
var InputFilter = ;var rules = 'name': 'required': true 'preFilters': 'trim' 'age': 'required': false // also FALSE if absent 'preFilters': 'trim' 'validators': 'isInt' 'postFilters': 'toInt' ;var data = name: " dV " age: ' 29 '; var inputFilter = rules;inputFilter;
Writing you own filters and validators.
NOTE:
- filters work in synchronous way while validators are expected to be asynchronous
var _ = ;var MongoClient = MongoClient;MongoClient;