contact.js 867 B

1234567891011121314151617181920212223242526272829303132
  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. const schemaUpdatePin = Joi.object({
  14. id: Joi.string().required(),
  15. pinned: Joi.boolean().required(),
  16. });
  17. module.exports.createContact = (req, _res, next) => {
  18. return validate(schemaCreateContact, req.body, next);
  19. };
  20. module.exports.updateContact = (req, _res, next) => {
  21. return validate(schemaUpdateContact, req.body, next);
  22. };
  23. module.exports.updatePin = (req, _res, next) => {
  24. return validate(schemaUpdatePin, req.body, next);
  25. };