UNPKG

datatypes-validation

Version:

![](https://img.shields.io/npm/v/datatypes-validation.svg) ![](https://img.shields.io/npm/dm/datatypes-validation.svg) ![](coverage/badge-lines.svg) ![](coverage/badge-functions.svg) ![](coverage/badge-statements.svg) ![](coverage/badge-branches.svg)

67 lines 2.27 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const Rules_1 = require("../Rules"); const DateRules_1 = require("./DateRules"); const isRequired_1 = require("../SingleRulesFunctions/isRequired"); const isString_1 = require("../SingleRulesFunctions/isString"); const isEmail_1 = require("../SingleRulesFunctions/isEmail"); const equalTo_1 = require("../SingleRulesFunctions/equalTo"); const defaultValue_1 = require("../SingleRulesFunctions/defaultValue"); const isDate_1 = require("../SingleRulesFunctions/isDate"); const custom_1 = require("../SingleRulesFunctions/custom"); const minLength_1 = require("../SingleRulesFunctions/minLength"); const maxLength_1 = require("../SingleRulesFunctions/maxLength"); class StringRules extends Rules_1.Rules { isRequired(options = {}) { this.rules.required = isRequired_1.isRequired(options); return this; } get required() { return this.isRequired(); } isString(options = {}) { this.rules.string = isString_1.isString(options); return this; } get string() { return this.isString(); } isEmail(options = {}) { this.rules.email = isEmail_1.isEmail(options); return this; } get email() { return this.isEmail(); } equalTo(values, options = {}) { this.rules.equalTo = equalTo_1.equalTo(values, options); return this; } defaultValue(value) { this.rules.defaultValue = defaultValue_1.defaultValue(value); return this; } isDate(options = {}) { const rulesInstace = new DateRules_1.DateRules(); rulesInstace.rules = this.rules; rulesInstace.rules.date = isDate_1.isDate(options); return rulesInstace; } get date() { return this.isDate(); } custom(callback) { this.rules.custom = custom_1.custom(callback); return this; } minLength(min, options = {}) { this.rules.minLength = minLength_1.minLength(min, options); return this; } maxLength(max, options = {}) { this.rules.maxLength = maxLength_1.maxLength(max, options); return this; } } exports.StringRules = StringRules; //# sourceMappingURL=StringRules.js.map