UNPKG

nowjs-core

Version:

NowCanDo Javascript Core [nowjs-core] is a library written by TypeScript code maintains under Apache 2.0 licence

46 lines (45 loc) 1.5 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const index_1 = require("../utils/index"); const index_2 = require("./index"); class ValidationContext { constructor(target, propertyName) { this.target = target; this.propertyName = propertyName; this._value = index_1.getObjetctNestedPath(target, propertyName, index_2.VALIDATION_PROPERTYPATH_SEPRATOR); if (propertyName) { this._displayName = index_1.getObjectLastKeyOfPath(target, propertyName, index_2.VALIDATION_PROPERTYPATH_SEPRATOR); this._displayName = index_1.getReflectdDisplayName(target, propertyName, this._displayName); } else { this._displayName = propertyName; } } setOwnProperty(name, value) { if (!name || typeof name !== 'string' || name === '') return; this[name] = value; } getOwnProperty(name) { if (!name || typeof name !== 'string' || name === '') return; return this[name]; } get Target() { return this.target; } get PropertyName() { return this.propertyName; } get DisplayName() { return this._displayName; } get Value() { if (!this.target) return this.target; if (!this.propertyName || typeof this.propertyName !== 'string') return this.target; return this._value; } } exports.ValidationContext = ValidationContext;