UNPKG

markdown-proofing

Version:

A markdown proofing platform for individuals, teams, and organizations.

40 lines (31 loc) 1.54 kB
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } var Validator = function () { function Validator() { _classCallCheck(this, Validator); } _createClass(Validator, null, [{ key: 'isValidMessageType', value: function isValidMessageType(messageType) { if (!messageType || typeof messageType !== 'string') { return false; } return messageType.match(/[^a-z0-9-]/) === null; } }, { key: 'ensureValidMessageType', value: function ensureValidMessageType(messageType) { var isValid = this.isValidMessageType(messageType); if (!isValid) { throw new Error(messageType + ' is not a valid message type.'); } } }]); return Validator; }(); exports.default = Validator; module.exports = exports['default'];