You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

groupings.js 855B

12345678910111213141516171819202122232425262728293031323334
  1. const Joi = require('joi')
  2. const profileSchema = require('./profiles')
  3. /**
  4. * Groupings
  5. * A represents a match, an organization, or anything else
  6. * that relates multiple profiles to each other.
  7. */
  8. // validator is used to validate route input/output
  9. const validator = Joi.object({
  10. grouping_id: Joi.number(),
  11. grouping_name: Joi.string(),
  12. grouping_type: Joi.string(),
  13. is_paired: Joi.boolean(),
  14. profile: profileSchema.validator,
  15. }).label('grouping__single_validator')
  16. const list = Joi.array().items(validator).label('grouping__list_validator')
  17. // single is used to define database models
  18. const single = Joi.object({
  19. grouping_id: Joi.number(),
  20. grouping_name: Joi.string(),
  21. grouping_type: Joi.string(),
  22. is_paired: Joi.boolean(),
  23. }).label('grouping__single')
  24. module.exports = {
  25. single,
  26. validator,
  27. list,
  28. }