UNPKG

carbon-react

Version:

A library of reusable React components and an interface for easily building user interfaces based on Flux.

60 lines (45 loc) 1.41 kB
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _validations = require('./../../helpers/validations'); var _validations2 = _interopRequireDefault(_validations); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /** * This will validate a value for being blank. * * @constructor IsBlankValidator */ var IsBlankValidator = /** * @method constructor * @param {Object} params */ function IsBlankValidator() { var _this = this; var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; _classCallCheck(this, IsBlankValidator); this.validate = function (value) { return !value; }; this.message = function () { return _validations2.default.validationMessage(_this.customMessage, 'errors.messages.must_be_blank'); }; this.customMessage = params.customMessage; } /** * This will validate the given value, and return a valid status. * * @method validate * @param {Object} value to check * @return {Boolean} true if value is valid */ /** * This is the message returned when this validation fails. * * @method message * @return {String} the error message to display */ ; exports.default = IsBlankValidator;