1234567891011121314151617181920212223242526272829303132 |
- const Joi = require('joi');
- const validate = require('./validate');
- const schemaCreateContact = Joi.object({
- number: Joi.string().min(8).max(14).required(),
- });
- const schemaUpdateContact = Joi.object({
- id: Joi.string().required(),
- _id: Joi.string().required(),
- name: Joi.string().min(1).max(30).trim().required(),
- lastName: Joi.string().min(1).max(30).trim().required(),
- companionId: Joi.string().min(1).required(),
- });
- const schemaUpdatePin = Joi.object({
- id: Joi.string().required(),
- pinned: Joi.boolean().required(),
- });
- module.exports.createContact = (req, _res, next) => {
- return validate(schemaCreateContact, req.body, next);
- };
- module.exports.updateContact = (req, _res, next) => {
- return validate(schemaUpdateContact, req.body, next);
- };
- module.exports.updatePin = (req, _res, next) => {
- return validate(schemaUpdatePin, req.body, next);
- };
|