mongoose-auto-api.validation

1.0.1 • Public • Published

Mongoose Auto API - Validations Module

Build Status npm version

Automatic Mongoose REST API - Validations Module ☕

Install

  • npm i -S mongoose-auto-api.validation

Model Setup

Usage

validation = require('mongoose-auto-api.validation')

Methods

  • All methods return object
    • messages (Array)
      • list of error messages
    • codes (Array)
      • list of error codes
    • valid (Boolean)
      • returns true if valid input, false otherwise
  • userVal(text, field)
    • text (String) - text to validate
    • field (String) - field name for error messages/codes generation
    • Assures input is not empty, longer than 8 characters, and is a valid email
  • passVal(text, field)
    • text (String) - text to validate
    • field (String) - field name for error messages/codes generation
    • Assures input is not empty, longer than 8 characters, and is a valid password with at least one lowercase, capital, numeric, and special character
  • confirmPassVal(text, password, field)
    • text (String) - text to validate
    • password (String) - confirmation text to check for match
    • field (String) - field name for error messages/codes generation
    • Assures input is not empty, and that input and confirmation password match
  • requiredVal(text, field)
    • text (String) - text to validate
    • field (String) - field name for error messages/codes generation
    • Assures input is not empty
  • lengthVal(text, field)
    • text (String) - text to validate
    • field (String) - field name for error messages/codes generation
    • length (Number) - minimum text length
    • Assures input length is greater than or equal to length
  • joinValidations(vals)
    • vals (Array) - list of validation objects
    • returns joined validation object with all messages, and error codes
    • if any validations are false, valid will return false

Package Sidebar

Install

npm i mongoose-auto-api.validation

Weekly Downloads

1

Version

1.0.1

License

MIT

Unpacked Size

13.6 kB

Total Files

5

Last publish

Collaborators

  • edmundpf