Comparing version 1.0.0-pre-33 to 1.0.0-pre-34
@@ -1,2 +0,2 @@ | ||
import type { DryvOptions, DryvProxy, DryvValidationRuleSet } from './typings'; | ||
import { DryvOptions, DryvProxy, DryvValidationRuleSet } from './typings'; | ||
export declare function annotate<TModel extends object>(model: DryvProxy<TModel>, ruleSet: DryvValidationRuleSet<TModel>, options: DryvOptions): void; |
import { isDryvValidatable } from './'; | ||
export function annotate(model, ruleSet, options) { | ||
annotateObject(model.$validatable, ruleSet, options); | ||
annotateDryvObject(model.$validatable.value, ruleSet, options); | ||
} | ||
function annotateObject(validatable, ruleSet, options) { | ||
function annotateDryvObject(dryvObject, ruleSet, options) { | ||
var _a; | ||
const model = validatable.value; | ||
for (const key in model) { | ||
for (const key in dryvObject) { | ||
if ((_a = options.excludedFields) === null || _a === void 0 ? void 0 : _a.find((regexp) => regexp.test(key))) { | ||
continue; | ||
} | ||
const value = model[key]; | ||
const value = dryvObject[key]; | ||
if (isDryvValidatable(value)) { | ||
annotateValidatable(value, ruleSet); | ||
} | ||
if (typeof value === 'object') { | ||
annotateObject(value, ruleSet, options); | ||
else if (typeof value === 'object') { | ||
annotateDryvObject(value, ruleSet, options); | ||
} | ||
@@ -23,4 +22,5 @@ } | ||
var _a, _b; | ||
validatable.required = !!((_b = (_a = ruleSet.validators) === null || _a === void 0 ? void 0 : _a[validatable.field]) === null || _b === void 0 ? void 0 : _b.find((rule) => { var _a; return (_a = rule.annotations) === null || _a === void 0 ? void 0 : _a.required; })); | ||
console.log('***', validatable.path); | ||
validatable.required = !!((_b = (_a = ruleSet.validators) === null || _a === void 0 ? void 0 : _a[validatable.path]) === null || _b === void 0 ? void 0 : _b.find((rule) => { var _a; return (_a = rule.annotations) === null || _a === void 0 ? void 0 : _a.required; })); | ||
} | ||
//# sourceMappingURL=annotate.js.map |
{ | ||
"name": "dryvjs", | ||
"version": "1.0.0-pre-33", | ||
"version": "1.0.0-pre-34", | ||
"main": "dist/index.js", | ||
@@ -5,0 +5,0 @@ "types": "dist/index.d.ts", |
Sorry, the diff of this file is not supported yet
83165