0.1.0 • Published 6 years ago

trailpack-validator v0.1.0

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

trailpack-validator

Usage

npm install --save trailpack-validator
// api/validators/SomeValidator.js

import Validator from 'trailpack-validator/validator';

export default class UserValidator extends Validator {
  register() {
    return {
      body: {
        firstName: {
          notEmpty: true
        },
        lastName: {
          notEmpty: true
        },
        email: {
          isEmail: true
        },
        username: {
          notEmpty: true
        },
        password: {
          notEmpty: true
        }
      }
    };
  }

  login() {
    return {
      body: {
        email: {
          isEmail: true
        },
        password: {
          notEmpty: true
        }
      }
    };
  }
}
// config/validators.js

export default {

  UserController: {
    register: ['UserValidator.register'],
    login: ['UserValidator.login']
  }
};