xml-name-validator.js 449 B

123456789101112131415161718
  1. "use strict";
  2. const parser = require("./generated-parser.js");
  3. exports.name = function (potentialName) {
  4. return mapResult(parser.startWith("Name").exec(potentialName));
  5. };
  6. exports.qname = function (potentialQname) {
  7. return mapResult(parser.startWith("QName").exec(potentialQname));
  8. };
  9. function mapResult(result) {
  10. return {
  11. success: result.success,
  12. error: result.error && parser.getTrace(result.error.message)
  13. };
  14. }