@a-a-game-studio/aa-components
Advanced tools
Comparing version 1.1.45 to 1.1.46
@@ -7,5 +7,5 @@ import { ErrorSys } from "./ErrorSys/ErrorSys"; | ||
import { ModelRulesC } from "./ModelValidatorSys/ModelRulesC"; | ||
import { ModelRulesT } from "./ModelValidatorSys/ModelRulesE"; | ||
import { ModelRulesT, TCustomFn } from "./ModelValidatorSys/ModelRulesE"; | ||
import { BaseClass } from "./BaseClass"; | ||
import { FieldValidator } from "./FieldValidator/FieldValidator"; | ||
export { ErrorSys, ErrorT, ErrorMsgT, SimpleI, FieldValidator, ModelValidatorSys, ModelOneRuleC, ModelRulesC, ModelRulesT, BaseClass, }; | ||
export { ErrorSys, ErrorT, ErrorMsgT, SimpleI, FieldValidator, ModelValidatorSys, ModelOneRuleC, ModelRulesC, ModelRulesT, BaseClass, TCustomFn, }; |
import { ModelRulesT } from ".."; | ||
import { TCustomFn } from "./ModelRulesE"; | ||
/** | ||
@@ -115,2 +116,6 @@ * Класс конструирующий правила для одного поля | ||
/** | ||
* Кастомная валидация | ||
*/ | ||
custom(fnVal: TCustomFn): ModelOneRuleC; | ||
/** | ||
* Получить правило | ||
@@ -117,0 +122,0 @@ * |
@@ -197,2 +197,9 @@ "use strict"; | ||
/** | ||
* Кастомная валидация | ||
*/ | ||
ModelOneRuleC.prototype.custom = function (fnVal) { | ||
this.aRule.custom = fnVal; | ||
return this; | ||
}; | ||
/** | ||
* Получить правило | ||
@@ -199,0 +206,0 @@ * |
@@ -0,1 +1,3 @@ | ||
import { ErrorSys } from '../ErrorSys/ErrorSys'; | ||
export declare type TCustomFn = (data: any, errorSys: ErrorSys) => boolean; | ||
/** Типы валидации */ | ||
@@ -21,2 +23,3 @@ export interface ModelRulesI { | ||
less_or_equal?: number; | ||
custom?: TCustomFn; | ||
before_action?: Function; | ||
@@ -23,0 +26,0 @@ } |
@@ -146,2 +146,6 @@ import { ErrorSys } from '../ErrorSys/ErrorSys'; | ||
private fMinLen; | ||
/** | ||
* Кастомная валидация | ||
*/ | ||
private fCustom; | ||
} |
@@ -145,2 +145,5 @@ "use strict"; | ||
} | ||
if (bExist && 'custom' in v) { | ||
this.fCustom(k, v); | ||
} | ||
// ============================================ | ||
@@ -460,2 +463,13 @@ // Если поле обязательно, но указанно неправильно - подставить значение по умолчанию если есть | ||
}; | ||
/** | ||
* Кастомная валидация | ||
*/ | ||
ModelValidatorSys.prototype.fCustom = function (kRule, vRule) { | ||
this.okResult = vRule.custom(this.data[kRule], this.errorSys); | ||
if (this.okResult) { | ||
this.abValidOK[kRule] = true; | ||
this.aResult[kRule] = this.data[kRule]; | ||
} | ||
return true; | ||
}; | ||
return ModelValidatorSys; | ||
@@ -462,0 +476,0 @@ }()); |
{ | ||
"name": "@a-a-game-studio/aa-components", | ||
"version": "1.1.45", | ||
"version": "1.1.46", | ||
"description": "node typescript base class", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
172502
41
3173