contact.js 655 B

1234567891011121314151617181920212223
  1. const Joi = require('joi');
  2. const validate = require('./validate');
  3. const schemaCreateContact = Joi.object({
  4. number: Joi.string().min(8).max(14).required(),
  5. });
  6. const schemaUpdateContact = Joi.object({
  7. id: Joi.string().required(),
  8. _id: Joi.string().required(),
  9. name: Joi.string().min(1).max(30).trim().required(),
  10. lastName: Joi.string().min(1).max(30).trim().required(),
  11. companionId: Joi.string().min(1).required(),
  12. });
  13. module.exports.createContact = (req, _res, next) => {
  14. return validate(schemaCreateContact, req.body, next);
  15. };
  16. module.exports.updateContact = (req, _res, next) => {
  17. return validate(schemaUpdateContact, req.body, next);
  18. };