1234567891011121314151617181920212223 |
- 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).optional().trim().optional(),
- lastName: Joi.string().min(1).max(30).optional().trim().optional(),
- companionId: Joi.string().min(1).optional(),
- }).min(2);
- module.exports.createContact = (req, _res, next) => {
- return validate(schemaCreateContact, req.body, next);
- };
- module.exports.updateContact = (req, _res, next) => {
- return validate(schemaUpdateContact, req.body, next);
- };
|