Comparing version 1.0.0-pre-95 to 1.0.0-pre-96
@@ -16,3 +16,3 @@ import { DryvArrayValidator } from './DryvArrayValidator'; | ||
} | ||
const validator = new DryvFieldValidator(model, session, parent, options, field, value); | ||
const validator = new DryvFieldValidator(model, session, parent, options, field); | ||
const rules = session.ruleSet.validators[(_a = validator.path) !== null && _a !== void 0 ? _a : '']; | ||
@@ -19,0 +19,0 @@ validator.required = !!(rules === null || rules === void 0 ? void 0 : rules.find((rule) => { var _a; return !!((_a = rule.annotations) === null || _a === void 0 ? void 0 : _a.required); })); |
@@ -5,5 +5,4 @@ import type { DryvValidationResult, DryvValidationSession } from './'; | ||
export declare class DryvFieldValidator<TModel extends object, TParameters = any> extends DryvValidator<TModel, TParameters, DryvCompositeValidator> { | ||
private _initialValue?; | ||
private _value?; | ||
constructor(model: TModel, session: DryvValidationSession, parent: DryvCompositeValidator, options: DryvOptions, field: keyof TModel, value?: any); | ||
private _initialValue; | ||
constructor(model: TModel, session: DryvValidationSession, parent: DryvCompositeValidator, options: DryvOptions, field: keyof TModel); | ||
get value(): any; | ||
@@ -10,0 +9,0 @@ set value(value: any); |
@@ -12,22 +12,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
export class DryvFieldValidator extends DryvValidator { | ||
constructor(model, session, parent, options, field, value) { | ||
constructor(model, session, parent, options, field) { | ||
super(model, session, parent, options, field); | ||
if (model && field) { | ||
this._initialValue = model[field]; | ||
} | ||
else { | ||
this._value = options.reactiveWrapper({ value }); | ||
} | ||
this._initialValue = model[field]; | ||
} | ||
get value() { | ||
var _a; | ||
return this.field && this.model ? this.model[this.field] : (_a = this._value) === null || _a === void 0 ? void 0 : _a.value; | ||
return this.model[this.field]; | ||
} | ||
set value(value) { | ||
if (this.field && this.model) { | ||
this.model[this.field] = value; | ||
} | ||
else if (this._value) { | ||
this._value.value = value; | ||
} | ||
this.model[this.field] = value; | ||
} | ||
@@ -34,0 +23,0 @@ refreshDirty() { |
@@ -1,2 +0,2 @@ | ||
import { DryvFieldValidationResult, DryvOptions, DryvValidationResult, DryvValidationRule, DryvValidationRuleSet, DryvValidator } from '.'; | ||
import { DryvFieldValidationResult, DryvOptions, DryvValidationResult, DryvValidationRule, DryvValidationRuleSet, DryvValidator } from './.'; | ||
import { DryvCompositeValidator } from './DryvCompositeValidator'; | ||
@@ -3,0 +3,0 @@ export declare class DryvValidationSession<TModel extends object = any, TParameters = any> { |
@@ -165,5 +165,5 @@ export class DryvValidator { | ||
toJSON() { | ||
return Object.assign(Object.assign({}, this), { value: this.value, path: this.path, text: this.text, hasError: this.hasError, hasWarning: this.hasWarning, isSuccess: this.isSuccess, uniquePath: this.uniquePath, index: this.index, _parent: undefined, _path: undefined, _rootModel: undefined, _rootValidator: undefined, _reactive: undefined, _initialValue: undefined, _value: undefined, _index: undefined, _ignoreChildChanges: undefined, _isReverting: undefined, _items: undefined, _uniquePath: undefined, rootValidator: undefined, rootModel: undefined, parent: undefined, model: undefined, proxy: undefined, session: undefined, options: undefined, transparentProxy: undefined }); | ||
return Object.assign(Object.assign({}, this), { value: this.value, path: this.path, text: this.text, hasError: this.hasError, hasWarning: this.hasWarning, isSuccess: this.isSuccess, uniquePath: this.uniquePath, _parent: undefined, _path: undefined, _rootModel: undefined, _rootValidator: undefined, _reactive: undefined, _initialValue: undefined, _ignoreChildChanges: undefined, _isReverting: undefined, _items: undefined, _uniquePath: undefined, rootValidator: undefined, rootModel: undefined, parent: undefined, model: undefined, proxy: undefined, session: undefined, options: undefined, transparentProxy: undefined }); | ||
} | ||
} | ||
//# sourceMappingURL=DryvValidator.js.map |
{ | ||
"name": "dryvjs", | ||
"version": "1.0.0-pre-95", | ||
"version": "1.0.0-pre-96", | ||
"main": "dist/index.js", | ||
@@ -12,3 +12,3 @@ "types": "dist/index.d.ts", | ||
"dev": "tsc && (concurrently \"tsc -w\" \"tsc-alias -w\")", | ||
"build": "tsc", | ||
"build": "tsc && tsc-alias", | ||
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore", | ||
@@ -15,0 +15,0 @@ "format": "prettier --write src/" |
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
88704
65
1324