2.0.0 • Published 5 years ago

n-validators v2.0.0

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

n-validators

JavaScript valiators.

Build Status Code Coverage npm version

Commands

# Install
$ npm i -S n-validators

Usage

const validators = require('validators');

let r1 = validators.isId(11); // r1 - true
let r2 = validators.isId('invalid id'); // r2 - false

API

  • isDateString(val, format) Returns true if val is a valid date string in format or in default format YYYY-MM-DDThh:mm:ss.

  • isNotEmptyString(val) Returns true if val is not an empty string.

  • isId(val) Returns true if val is a valid id (a positive integer number).

  • everyIsId(items) Returns true if items is an array with valid id elements.

  • everyIsUniqueId(items) Returns true if items is an array with valid, unique id elements.

  • isObjectId(val) Returns true if val is a valid ObjectId.

  • everyIsObjectId(items) Returns true if items is an array with valid ObjectId elements.

  • everyIsUniqueObjectId(items) Returns true if items is an array with valid, unique ObjectId elements.

  • everyIsObjectIdOrNull(items) Returns true if items is an array with valid ObjectId or null elements.

  • everyIsUniqueObjectIdOrNull(items) Returns true if items is an array with valid, unique ObjectId or null elements.

  • isEmail(val) Returns true if val is a valid email.

  • isSimplePhoneNumber(val) Returns true if val is a valid phone number (a string with digits started from +).

  • everyIsAllowed(items, allowed) Returns true if items is an array with elements from allowed.

  • everyIsUniqueAllowed(items, allowed) Returns true if items is an array of unique elements from allowed.

  • isFieldsString(val, allowed) Returns true if val is a string of fields separated by space from allowed.

Author

Alexander Mac

License

MIT License

2.0.0

5 years ago

2.0.0-alpha-2

6 years ago

2.0.0-alpha

6 years ago

1.1.0

6 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago