Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 
 

45 righe
1.1 KiB

  1. 'use strict';
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. /**
  6. * JSON schema to accept an array of unique strings
  7. */
  8. var arraySchema = exports.arraySchema = {
  9. type: 'array',
  10. items: {
  11. type: 'string'
  12. },
  13. uniqueItems: true,
  14. additionalItems: false
  15. };
  16. /**
  17. * JSON schema to accept an array of unique strings from an enumerated list.
  18. */
  19. var enumArraySchema = exports.enumArraySchema = function enumArraySchema() {
  20. var enumeratedList = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
  21. var minItems = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
  22. return Object.assign({}, arraySchema, {
  23. items: {
  24. type: 'string',
  25. enum: enumeratedList
  26. },
  27. minItems: minItems
  28. });
  29. };
  30. /**
  31. * Factory function to generate an object schema
  32. * with specified properties object
  33. */
  34. var generateObjSchema = exports.generateObjSchema = function generateObjSchema() {
  35. var properties = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  36. var required = arguments[1];
  37. return {
  38. type: 'object',
  39. properties: properties,
  40. required: required
  41. };
  42. };