celebrate#Segments TypeScript Examples

The following examples show how to use celebrate#Segments. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: users.routes.ts    From gobarber-project with MIT License 6 votes vote down vote up
usersRouter.post(
  '/',
  celebrate({
    [Segments.BODY]: {
      name: Joi.string().required(),
      email: Joi.string().email().required(),
      password: Joi.string().required(),
    },
  }),
  usersController.create,
);
Example #2
Source File: PointsValidator.ts    From NLW-1.0 with MIT License 6 votes vote down vote up
storeValidator = celebrate(
  {
    [Segments.BODY]: Joi.object().keys({
      name: Joi.string().required(),
      email: Joi.string().required().email(),
      whatsapp: Joi.string().required(),
      city: Joi.string().required(),
      uf: Joi.string().required().length(2),
      latitude: Joi.number().required(),
      longitude: Joi.number().required(),
      items: Joi.string().required(),
    }),
  },
  {
    abortEarly: false,
  },
)
Example #3
Source File: appointments.routes.ts    From gobarber-project with MIT License 6 votes vote down vote up
appointmentsRouter.post(
  '/',
  celebrate({
    [Segments.BODY]: {
      provider_id: Joi.string().uuid().required(),
      date: Joi.date(),
    },
  }),
  appointmentsController.create,
);
Example #4
Source File: providers.routes.ts    From gobarber-project with MIT License 6 votes vote down vote up
providersRouter.get(
  '/:provider_id/month-availability',
  celebrate({
    [Segments.PARAMS]: {
      provider_id: Joi.string().uuid().required(),
    },
  }),
  providerMonthAvailabilityController.index,
);
Example #5
Source File: providers.routes.ts    From gobarber-project with MIT License 6 votes vote down vote up
providersRouter.get(
  '/:provider_id/day-availability',
  celebrate({
    [Segments.PARAMS]: {
      provider_id: Joi.string().uuid().required(),
    },
  }),
  providerDayAvailabilityController.index,
);
Example #6
Source File: password.routes.ts    From gobarber-project with MIT License 6 votes vote down vote up
passwordRouter.post(
  '/forgot',
  celebrate({
    [Segments.BODY]: {
      email: Joi.string().email().required(),
    },
  }),
  forgotPasswordController.create,
);
Example #7
Source File: password.routes.ts    From gobarber-project with MIT License 6 votes vote down vote up
passwordRouter.post(
  '/reset',
  celebrate({
    [Segments.BODY]: {
      token: Joi.string().uuid().required(),
      password: Joi.string().required(),
      password_confirmation: Joi.string().required().valid(Joi.ref('password')),
    },
  }),
  resetPasswordController.create,
);
Example #8
Source File: profile.routes.ts    From gobarber-project with MIT License 6 votes vote down vote up
profileRouter.put(
  '/',
  celebrate({
    [Segments.BODY]: {
      name: Joi.string().required(),
      email: Joi.string().email().required(),
      old_password: Joi.string(),
      password: Joi.string(),
      password_confirmation: Joi.string().valid(Joi.ref('password')),
    },
  }),
  profileController.update,
);
Example #9
Source File: sessions.routes.ts    From gobarber-project with MIT License 6 votes vote down vote up
sessionsRouter.post(
  '/',
  celebrate({
    [Segments.BODY]: {
      email: Joi.string().email().required(),
      password: Joi.string().required(),
    },
  }),
  sessionsController.create,
);
Example #10
Source File: updateProfile.ts    From hotseat-api with MIT License 6 votes vote down vote up
updateProfileValidator = celebrate({
  [Segments.BODY]: Joi.object({
    name: Joi.string().not().empty(),
    email: Joi.string().email().not().empty(),
    password: Joi.string().min(5),
    password_confirmation: Joi.any().valid(Joi.ref('password')),
    old_password: Joi.string().min(5),
  })
    .with('password', 'password_confirmation')
    .with('password', 'old_password'),
})
Example #11
Source File: appointments.routes.ts    From GoBarber with MIT License 6 votes vote down vote up
appointmentsRouter.post(
  '/',
  celebrate({
    [Segments.BODY]: {
      provider_id: Joi.string().uuid().required(),
      date: Joi.date(),
    },
  }),
  appointmentsController.create,
);
Example #12
Source File: providers.routes.ts    From GoBarber with MIT License 6 votes vote down vote up
providersRouter.get(
  '/:provider_id/month-availability',
  celebrate({
    [Segments.PARAMS]: {
      provider_id: Joi.string().uuid().required(),
    },
  }),
  providersMonthAvailabilityController.index,
);
Example #13
Source File: providers.routes.ts    From GoBarber with MIT License 6 votes vote down vote up
providersRouter.get(
  '/:provider_id/day-availability',
  celebrate({
    [Segments.PARAMS]: {
      provider_id: Joi.string().uuid().required(),
    },
  }),
  providersDayAvailabilityController.index,
);
Example #14
Source File: password.routes.ts    From GoBarber with MIT License 6 votes vote down vote up
passwordRouter.post(
  '/forgot',
  celebrate({
    [Segments.BODY]: {
      email: Joi.string().email().required(),
    },
  }),
  forgotPasswordController.create,
);
Example #15
Source File: password.routes.ts    From GoBarber with MIT License 6 votes vote down vote up
passwordRouter.post(
  '/reset',
  celebrate({
    [Segments.BODY]: {
      token: Joi.string().uuid().required(),
      password: Joi.string().required(),
      passwordConfirmation: Joi.string().valid(Joi.ref('password')),
    },
  }),
  resetPasswordController.create,
);
Example #16
Source File: profile.routes.ts    From GoBarber with MIT License 6 votes vote down vote up
profileRouter.put(
  '/',
  celebrate({
    [Segments.BODY]: {
      name: Joi.string().required(),
      email: Joi.string().required(),
      oldPassword: Joi.string(),
      password: Joi.string().when('oldPassword', {
        is: String,
        then: Joi.string().required(),
      }),
      passwordConfirmation: Joi.string().when('oldPassword', {
        is: String,
        then: Joi.string().required().valid(Joi.ref('password')),
      }),
    },
  }),
  profileController.update,
);
Example #17
Source File: sessions.routes.ts    From GoBarber with MIT License 6 votes vote down vote up
sessionsRouter.post(
  '/',
  celebrate({
    [Segments.BODY]: {
      email: Joi.string().email().required(),
      password: Joi.string().required(),
    },
  }),
  sessionsController.create,
);
Example #18
Source File: users.routes.ts    From GoBarber with MIT License 6 votes vote down vote up
usersRouter.post(
  '/',
  celebrate({
    [Segments.BODY]: {
      name: Joi.string().required(),
      email: Joi.string().email().required(),
      password: Joi.string().min(6).required(),
    },
  }),
  usersController.create,
);
Example #19
Source File: createAppointment.ts    From hotseat-api with MIT License 6 votes vote down vote up
createAppointmentValidator = celebrate({
  [Segments.BODY]: {
    type: Joi.string()
      .valid(...APPOINTMENT_TYPES)
      .required(),
    date: Joi.date(),
    provider_id: Joi.string().uuid().required(),
  },
})
Example #20
Source File: appointments.routes.ts    From gobarber-api with MIT License 6 votes vote down vote up
appointmentsRouter.post(
  '/',
  celebrate({
    [Segments.BODY]: {
      provider_id: Joi.string().uuid().required(),
      date: Joi.date().required(),
    },
  }),
  appointmentsController.craete,
);
Example #21
Source File: providers.routes.ts    From gobarber-api with MIT License 6 votes vote down vote up
providersRouter.get(
  '/:provider_id/day-availability',
  celebrate({
    [Segments.PARAMS]: {
      provider_id: Joi.string().uuid().required(),
    },
  }),
  providerDayAvailabilityController.index,
);
Example #22
Source File: providers.routes.ts    From gobarber-api with MIT License 6 votes vote down vote up
providersRouter.get(
  '/:provider_id/month-availability',
  celebrate({
    [Segments.PARAMS]: {
      provider_id: Joi.string().uuid().required(),
    },
  }),
  providerMonthAvailabilityController.index,
);
Example #23
Source File: passwords.routes.ts    From gobarber-api with MIT License 6 votes vote down vote up
passwordsRouter.post(
  '/forgot',
  celebrate({
    [Segments.BODY]: {
      email: Joi.string().email().required(),
    },
  }),
  forgotPasswordController.create,
);
Example #24
Source File: passwords.routes.ts    From gobarber-api with MIT License 6 votes vote down vote up
passwordsRouter.post(
  '/reset',
  celebrate({
    [Segments.BODY]: {
      token: Joi.string().uuid().required(),
      password: Joi.string().required(),
      password_confirmation: Joi.string().required().valid(Joi.ref('password')),
    },
  }),
  resetPasswordController.create,
);
Example #25
Source File: profiles.routes.ts    From gobarber-api with MIT License 6 votes vote down vote up
profilesRouter.put(
  '/',
  celebrate({
    [Segments.BODY]: {
      name: Joi.string().required(),
      email: Joi.string().email().required(),
      old_password: Joi.string(),
      password: Joi.string(),
      password_confirmation: Joi.string().valid(Joi.ref('password')),
    },
  }),
  profileController.update,
);
Example #26
Source File: sessions.routes.ts    From gobarber-api with MIT License 6 votes vote down vote up
sessionsRouter.post(
  '/',
  celebrate({
    [Segments.BODY]: {
      email: Joi.string().email().required(),
      password: Joi.string().required(),
    },
  }),
  sessionsController.create,
);
Example #27
Source File: users.routes.ts    From gobarber-api with MIT License 6 votes vote down vote up
usersRouter.post(
  '/',
  celebrate({
    [Segments.BODY]: {
      name: Joi.string().required(),
      email: Joi.string().email().required(),
      password: Joi.string().required(),
    },
  }),
  usersController.create,
);
Example #28
Source File: resetPassword.ts    From hotseat-api with MIT License 5 votes vote down vote up
resetPasswordValidator = celebrate({
  [Segments.BODY]: {
    password: Joi.string().min(5).required(),
    token: Joi.string().uuid().required(),
    confirm_password: Joi.any().valid(Joi.ref('password')).required(),
  },
})
Example #29
Source File: listProviderAppointments.ts    From hotseat-api with MIT License 5 votes vote down vote up
listProviderAppointmentsValidator = celebrate({
  [Segments.QUERY]: {
    day: Joi.number().integer().positive().required(),
    month: Joi.number().integer().positive().required(),
    year: Joi.number().integer().positive().required(),
  },
})