GSI - Employe Self Service Mobile
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.

29 lines
1.1 KiB

2 months ago
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.getErrorMessage = exports.getValidator = void 0;
  4. const fs = require("fs");
  5. const path = require("path");
  6. const Ajv = require("ajv");
  7. const ajv = new Ajv();
  8. let _VALIDATOR = undefined;
  9. function getValidator() {
  10. if (!_VALIDATOR) {
  11. const schemaStr = fs.readFileSync(path.resolve(__dirname, "../schema/firebase-config.json"), "utf-8");
  12. const schema = JSON.parse(schemaStr);
  13. _VALIDATOR = ajv.compile(schema);
  14. }
  15. return _VALIDATOR;
  16. }
  17. exports.getValidator = getValidator;
  18. function getErrorMessage(e) {
  19. if (e.keyword === "additionalProperties") {
  20. return `Object "${e.dataPath}" in "firebase.json" has unknown property: ${JSON.stringify(e.params)}`;
  21. }
  22. else if (e.keyword === "required") {
  23. return `Object "${e.dataPath}" in "firebase.json" is missing required property: ${JSON.stringify(e.params)}`;
  24. }
  25. else {
  26. return `Field "${e.dataPath}" in "firebase.json" is possibly invalid: ${e.message}`;
  27. }
  28. }
  29. exports.getErrorMessage = getErrorMessage;