mtr-validator
v1.0.1
Published
Library ini menggunakan [**express-validator v5.3.1**](https://www.npmjs.com/package/express-validator). ### Installation ```bash npm i git+ssh://[email protected]/mtr-platform/libs/validation#v1.0.1 ``` ### Penggunaan Deklarasikan validato
Downloads
4
Readme
Validation Formatter Library
Dependency
Library ini menggunakan express-validator v5.3.1.
Installation
npm i git+ssh://[email protected]/mtr-platform/libs/validation#v1.0.1
Penggunaan
Deklarasikan validator dalam app.js
.
const { validator } = require('mtr-validator');
app.use(validator());
Library dipanggil seperti contoh berikut:
const {
check, checkBody, checkCookies, checkHeaders, checkParams, checkQuery,
} = require('mtr-validator');
checkBody(req, {
fieldName: { validationType: validationValue },
});
Feature Pengecekan
check
- Pengecekan seluruh sumber requestcheckBody
- Hanya mengecek request bodycheckCookies
- Hanya mengecek request cookiescheckHeaders
- Hanya mengecek request headerscheckParams
- Hanya mengecek request paramscheckQuery
- Hanya mengecek request query
Daftar Validasi
- optional: Boolean
- equals: String / Integer
- notEqual: String / Integer
- isAfter: String
- isAlpha: String
- isAlphanumeric: Boolean
- isBefore: String
- isBoolean: Boolean
- isDataURI: Boolean
- isDate: Boolean
- isDateTime: Boolean
- isTime: Boolean
- isEmail: Boolean
- isEmpty: Boolean
- notEmpty: Boolean
- isFloat: Boolean
- isNumeric: Boolean
- isInt: Boolean
- isDecimal: Boolean
- isIn: Array
- between: Array
- notIn: Array
- isJSON: Boolean
- isLatLong: Boolean
- isLength: Integer
- isLowercase: Boolean
- isUppercase: Boolean
- isString: Boolean
- isURL: Boolean
- isUUID: String
- isMobilePhone: String
- isFileName: String
- isMaxFile: Integer
- isMimeType: Array
- custom: String / Boolean