Socket
Socket
Sign inDemoInstall

@rawmodel/core

Package Overview
Dependencies
1
Maintainers
1
Versions
35
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.3.0 to 3.3.1

6

CHANGELOG.json

@@ -5,2 +5,8 @@ {

{
"version": "3.3.1",
"tag": "@rawmodel/core_v3.3.1",
"date": "Thu, 03 Oct 2019 20:16:12 GMT",
"comments": {}
},
{
"version": "3.3.0",

@@ -7,0 +13,0 @@ "tag": "@rawmodel/core_v3.3.0",

7

CHANGELOG.md
# Change Log - @rawmodel/core
This log was last generated on Thu, 03 Oct 2019 15:49:09 GMT and should not be manually modified.
This log was last generated on Thu, 03 Oct 2019 20:16:12 GMT and should not be manually modified.
## 3.3.1
Thu, 03 Oct 2019 20:16:12 GMT
*Version update only*
## 3.3.0

@@ -6,0 +11,0 @@ Thu, 03 Oct 2019 15:49:09 GMT

4

dist/core/builder.js

@@ -7,3 +7,3 @@ "use strict";

};
Object.defineProperty(Klass, '$props', {
Object.defineProperty(Klass, '__props', {
value: {},

@@ -14,3 +14,3 @@ enumerable: false,

props.forEach((prop) => {
Klass.$props[prop.name] = Object.assign({}, prop);
Klass.__props[prop.name] = Object.assign({}, prop);
});

@@ -17,0 +17,0 @@ return Klass;

import { Prop } from './props';
import { ModelConfig, PropConfig, PropItem, PropError } from './types';
export declare class Model<Context = any> {
readonly $config: ModelConfig<Context>;
readonly $props: {
readonly __config: ModelConfig<Context>;
readonly __props: {
[key: string]: Prop;
};
static readonly $props: {
static readonly __props: {
[key: string]: PropConfig;

@@ -10,0 +10,0 @@ };

@@ -16,7 +16,7 @@ "use strict";

constructor(data, config) {
Object.defineProperty(this, '$config', {
Object.defineProperty(this, '__config', {
value: config || {},
enumerable: false,
});
Object.defineProperty(this, '$props', {
Object.defineProperty(this, '__props', {
value: {},

@@ -29,3 +29,3 @@ enumerable: false,

defineProps() {
const recipes = this.constructor['$props'];
const recipes = this.constructor['__props'];
for (const key in recipes) {

@@ -36,6 +36,6 @@ this.defineProp(key, recipes[key]);

defineProp(key, config) {
this.$props[key] = new props_1.Prop(Object.assign(Object.assign({}, config), { model: this }));
this.__props[key] = new props_1.Prop(Object.assign(Object.assign({}, config), { model: this }));
Object.defineProperty(this, key, {
get: () => this.$props[key].getValue(),
set: (value) => this.$props[key].setValue(value),
get: () => this.__props[key].getValue(),
set: (value) => this.__props[key].setValue(value),
enumerable: config.enumerable !== false,

@@ -46,6 +46,6 @@ configurable: false,

getContext() {
return utils_1.realize(this.$config.context) || null;
return utils_1.realize(this.__config.context) || null;
}
getParent() {
return this.$config.parent || null;
return this.__config.parent || null;
}

@@ -70,3 +70,3 @@ getAncestors() {

if (keys.length === 0) {
return this.$props[lastKey];
return this.__props[lastKey];
}

@@ -84,3 +84,3 @@ else if (utils_1.isInteger(lastKey)) {

Object.keys(data || {}).forEach((key) => {
const prop = this.$props[key];
const prop = this.__props[key];
if (prop) {

@@ -94,4 +94,4 @@ prop.setValue(data[key], strategy);

const data = {};
Object.keys(this.$props).forEach((key) => {
const value = this.$props[key].serialize(strategy);
Object.keys(this.__props).forEach((key) => {
const value = this.__props[key].serialize(strategy);
if (!utils_1.isUndefined(value)) {

@@ -128,29 +128,29 @@ data[key] = value;

reset() {
Object.keys(this.$props)
.forEach((key) => this.$props[key].reset());
Object.keys(this.__props)
.forEach((key) => this.__props[key].reset());
return this;
}
fake() {
Object.keys(this.$props)
.forEach((key) => this.$props[key].fake());
Object.keys(this.__props)
.forEach((key) => this.__props[key].fake());
return this;
}
empty() {
Object.keys(this.$props)
.forEach((key) => this.$props[key].empty());
Object.keys(this.__props)
.forEach((key) => this.__props[key].empty());
return this;
}
commit() {
Object.keys(this.$props)
.forEach((key) => this.$props[key].commit());
Object.keys(this.__props)
.forEach((key) => this.__props[key].commit());
return this;
}
rollback() {
Object.keys(this.$props)
.forEach((key) => this.$props[key].rollback());
Object.keys(this.__props)
.forEach((key) => this.__props[key].rollback());
return this;
}
freeze() {
Object.keys(this.$props)
.forEach((key) => this.$props[key].freeze());
Object.keys(this.__props)
.forEach((key) => this.__props[key].freeze());
return this;

@@ -162,13 +162,13 @@ }

isChanged() {
return Object.keys(this.$props)
.some((key) => this.$props[key].isChanged());
return Object.keys(this.__props)
.some((key) => this.__props[key].isChanged());
}
isValid() {
return !Object.keys(this.$props)
.some((key) => !this.$props[key].isValid());
return !Object.keys(this.__props)
.some((key) => !this.__props[key].isValid());
}
validate({ quiet = false } = {}) {
return __awaiter(this, void 0, void 0, function* () {
yield Promise.all(Object.keys(this.$props)
.map((key) => this.$props[key].validate()));
yield Promise.all(Object.keys(this.__props)
.map((key) => this.__props[key].validate()));
if (!quiet && !this.isValid()) {

@@ -190,4 +190,4 @@ const error = new Error('Validation failed');

}
yield Promise.all(Object.keys(this.$props)
.map((n) => this.$props[n].handle(error)));
yield Promise.all(Object.keys(this.__props)
.map((n) => this.__props[n].handle(error)));
if (!quiet && !this.isValid()) {

@@ -219,12 +219,12 @@ const error = new Error('Validation failed');

invalidate() {
Object.keys(this.$props)
.forEach((key) => this.$props[key].invalidate());
Object.keys(this.__props)
.forEach((key) => this.__props[key].invalidate());
return this;
}
clone(data = {}) {
return new this.constructor(Object.assign(Object.assign({}, this.serialize()), data), Object.assign({}, this.$config));
return new this.constructor(Object.assign(Object.assign({}, this.serialize()), data), Object.assign({}, this.__config));
}
}
exports.Model = Model;
Model.$props = {};
Model.__props = {};
//# sourceMappingURL=models.js.map

@@ -8,3 +8,3 @@ import { PropConfig } from './types';

protected _frozen: boolean;
readonly $config: PropConfig;
readonly __config: PropConfig;
constructor(config?: PropConfig);

@@ -11,0 +11,0 @@ getModel(): any;

@@ -21,6 +21,6 @@ "use strict";

if (target.constructor.prototype && target.constructor.prototype.constructor) {
other = Object.assign({}, target.constructor.prototype.constructor.$props);
other = Object.assign({}, target.constructor.prototype.constructor.__props);
}
other[key] = Object.assign({}, config);
Object.defineProperty(target.constructor, '$props', {
Object.defineProperty(target.constructor, '__props', {
value: other,

@@ -37,12 +37,12 @@ enumerable: false,

this._frozen = false;
Object.defineProperty(this, '$config', {
Object.defineProperty(this, '__config', {
value: Object.assign({}, config),
enumerable: false,
});
this._initialValue = this._rawValue = utils_1.isUndefined(this.$config.defaultValue)
this._initialValue = this._rawValue = utils_1.isUndefined(this.__config.defaultValue)
? null
: this.$config.defaultValue;
: this.__config.defaultValue;
}
getModel() {
return utils_1.realize(this.$config.model);
return utils_1.realize(this.__config.model);
}

@@ -59,7 +59,7 @@ setValue(data, strategy) {

let value = utils_1.isUndefined(data) ? null : data;
if (this.$config.parser) {
if (this.__config.parser) {
value = this.parse(utils_1.realize(value, this.getModel()), strategy);
}
if (this.$config.setter) {
value = this.$config.setter.call(this.getModel(), utils_1.realize(value, this.getModel()));
if (this.__config.setter) {
value = this.__config.setter.call(this.getModel(), utils_1.realize(value, this.getModel()));
}

@@ -70,7 +70,7 @@ this._rawValue = value;

let value = utils_1.realize(this._rawValue, this.getModel());
if (this.$config.getter) {
value = this.$config.getter.call(this.getModel(), value);
if (this.__config.getter) {
value = this.__config.getter.call(this.getModel(), value);
}
if (!utils_1.isPresent(value) && !utils_1.isUndefined(this.$config.emptyValue)) {
value = utils_1.realize(this.$config.emptyValue, this.getModel());
if (!utils_1.isPresent(value) && !utils_1.isUndefined(this.__config.emptyValue)) {
value = utils_1.realize(this.__config.emptyValue, this.getModel());
}

@@ -92,14 +92,14 @@ return utils_1.isUndefined(value) ? null : value;

isArray() {
const { array } = this.$config.parser || {};
const { array } = this.__config.parser || {};
return array === true;
}
isPopulatable(strategy) {
return (this.$config.enumerable !== false
return (this.__config.enumerable !== false
&& (utils_1.isUndefined(strategy)
|| (this.$config.populatable || []).indexOf(strategy) !== -1));
|| (this.__config.populatable || []).indexOf(strategy) !== -1));
}
isSerializable(strategy) {
return (this.$config.enumerable !== false
return (this.__config.enumerable !== false
&& (utils_1.isUndefined(strategy)
|| (this.$config.serializable || []).indexOf(strategy) !== -1));
|| (this.__config.serializable || []).indexOf(strategy) !== -1));
}

@@ -133,3 +133,3 @@ isEmpty() {

parse(value, strategy) {
const parser = (this.$config.parser || {});
const parser = (this.__config.parser || {});
const recipe = {

@@ -149,3 +149,3 @@ resolver: parser.resolver,

else {
return new Klass(null, Object.assign(Object.assign({}, this.getModel().$config), { parent: this.getModel() })).populate(data, strategy);
return new Klass(null, Object.assign(Object.assign({}, this.getModel().__config), { parent: this.getModel() })).populate(data, strategy);
}

@@ -172,7 +172,7 @@ };

reset() {
this.setValue(this.$config.defaultValue);
this.setValue(this.__config.defaultValue);
return this;
}
fake() {
this.setValue(this.$config.fakeValue);
this.setValue(this.__config.fakeValue);
(utils_1.toArray(this._rawValue) || [])

@@ -205,3 +205,3 @@ .filter((doc) => utils_1.isInstanceOf(doc, models_1.Model))

let value = this._initialValue;
if (this.$config.parser) {
if (this.__config.parser) {
value = this.parse(value);

@@ -221,3 +221,3 @@ }

return __awaiter(this, void 0, void 0, function* () {
this._errorCode = yield validator_1.validate(this.getValue(), this.$config.validators, {
this._errorCode = yield validator_1.validate(this.getValue(), this.__config.validators, {
context: this.getModel(),

@@ -233,3 +233,3 @@ });

return __awaiter(this, void 0, void 0, function* () {
this._errorCode = yield handler_1.handle(error, this.$config.handlers, {
this._errorCode = yield handler_1.handle(error, this.__config.handlers, {
context: this.getModel(),

@@ -236,0 +236,0 @@ });

@@ -30,3 +30,3 @@ "use strict";

const descriptor = Object.getOwnPropertyDescriptor(user, 'name');
ctx.true(user.$props['name'] instanceof __1.Prop);
ctx.true(user.__props['name'] instanceof __1.Prop);
ctx.is(user.name, null);

@@ -33,0 +33,0 @@ ctx.is(typeof descriptor.get, 'function');

@@ -26,3 +26,3 @@ "use strict";

ctx.true(prop0.isValid());
prop0.$config.parser = { resolver: User };
prop0.__config.parser = { resolver: User };
user.getProp('name').setErrorCode(200);

@@ -29,0 +29,0 @@ ctx.false(prop0.isValid());

@@ -5,12 +5,12 @@ {

"packages/rawmodel-core/.npmignore": "417dbeccc3958deb2d45197baad0d9adfc323e4a",
"packages/rawmodel-core/CHANGELOG.json": "7445ae14eb9825812a36969f470c932ba31b537f",
"packages/rawmodel-core/CHANGELOG.md": "52b053ac509a391c209b7c1e82aa9e96955df22a",
"packages/rawmodel-core/CHANGELOG.json": "9582fb9478bcb31db1d082215d731f1467e01f8b",
"packages/rawmodel-core/CHANGELOG.md": "a1e279cb97d76c5f44efee71c80ce6a3c4c2c7cf",
"packages/rawmodel-core/README.md": "9100e8d2ce99a50ded1858a48ce98dd6522b1251",
"packages/rawmodel-core/nodemon.json": "82b893373db9861f1df4b55d8ea68a5d37b118de",
"packages/rawmodel-core/package.json": "324a801966506b744142c14ee0f63aa4dc6f00f9",
"packages/rawmodel-core/src/core/builder.ts": "aafdb04c8e5db388f10d70ef82732b53c4567044",
"packages/rawmodel-core/package.json": "2d3f9d376db3d56195fa60b7d7fe41eb9a6e2ff8",
"packages/rawmodel-core/src/core/builder.ts": "0955badf652c46f42dfcd8ae81bea5a1b3b00cf1",
"packages/rawmodel-core/src/core/handler.ts": "ff5a11200d625b06528db9c76451d0bca14cad1e",
"packages/rawmodel-core/src/core/models.ts": "c5c33b8f9e43972a9f5e712d559356515b9b0fbb",
"packages/rawmodel-core/src/core/models.ts": "0bf6352a824b631eb6f214d5bc01801284e7c6c2",
"packages/rawmodel-core/src/core/parser.ts": "c339e4cb88ca9f67c7ecaccdba158cb3f9236ccf",
"packages/rawmodel-core/src/core/props.ts": "514d113d39c367dfe491cb74b29d2ce0d68a0a27",
"packages/rawmodel-core/src/core/props.ts": "9c84f7217c1e36e1fd67fc284e75a6b93d58dba6",
"packages/rawmodel-core/src/core/types.ts": "b98126bf01ef43f1a341b9ec4121bc40dadd0d8b",

@@ -40,3 +40,3 @@ "packages/rawmodel-core/src/core/validator.ts": "236d92ef49dd14a61edb2dbf80f19314938deea5",

"packages/rawmodel-core/src/tests/core/models/populate-instance-method.test.ts": "3d0954921f99578a0a9be07cd10fcf9be609170e",
"packages/rawmodel-core/src/tests/core/models/prop-decorator.test.ts": "c1e919de54cd07ff10118ddf6a5c77b1426b0a07",
"packages/rawmodel-core/src/tests/core/models/prop-decorator.test.ts": "2d750a402194462b74e271b9d03b45a4001168fb",
"packages/rawmodel-core/src/tests/core/models/reset-instance-method.test.ts": "9ac953a6da4c1029197b9fcf1c57de55c2f1fff1",

@@ -64,3 +64,3 @@ "packages/rawmodel-core/src/tests/core/models/rollback-instance-method.test.ts": "802f492c978c448eb002ec40c9e7e126dee193f1",

"packages/rawmodel-core/src/tests/core/props/is-serializable-instance-method.test.ts": "a7e63ad222510472b44468b4849e1559d969634d",
"packages/rawmodel-core/src/tests/core/props/is-valid-instance-method.test.ts": "2b105da001efe9387fc7e120cdfd7e382ffcb212",
"packages/rawmodel-core/src/tests/core/props/is-valid-instance-method.test.ts": "bf0993e78678587d537383860b85e03167f3b919",
"packages/rawmodel-core/src/tests/core/props/reset-instance-method.test.ts": "d4220a9df7073babe030956b7217b203a38ebe98",

@@ -75,5 +75,5 @@ "packages/rawmodel-core/src/tests/core/props/rollback-instance-method.test.ts": "dfab98002857c2699eea1603a1ca31fb3bb48c73",

"packages/rawmodel-core/tslint.json": "88f5b48ff1a1024a2b414e5521474fd8a4f3d649",
"common/config/rush/npm-shrinkwrap.json": "1c28eb02a7ce835b5e4bcb25a937a63fb656f86f"
"common/config/rush/npm-shrinkwrap.json": "d194e4b06faad00212dd9a5e55233db8362c874e"
},
"arguments": "npx nyc npx hayspec test "
}
{
"name": "@rawmodel/core",
"version": "3.3.0",
"version": "3.3.1",
"description": "Strongly-typed JavaScript object with support for validation and error handling.",

@@ -87,3 +87,3 @@ "main": "./dist/index.js",

"@hayspec/spec": "^0.8.4",
"@rawmodel/parsers": "3.3.0",
"@rawmodel/parsers": "3.3.1",
"nyc": "^14.1.1",

@@ -95,4 +95,4 @@ "ts-node": "^8.3.0",

"dependencies": {
"@rawmodel/utils": "3.3.0"
"@rawmodel/utils": "3.3.1"
}
}

@@ -11,3 +11,3 @@ import { Model } from './models';

Object.defineProperty(Klass, '$props', {
Object.defineProperty(Klass, '__props', {
value: {},

@@ -19,3 +19,3 @@ enumerable: false,

props.forEach((prop) => {
Klass.$props[prop.name] = { ...prop };
Klass.__props[prop.name] = { ...prop };
});

@@ -22,0 +22,0 @@

@@ -10,5 +10,5 @@ import { Prop } from './props';

export class Model<Context = any> {
public readonly $config: ModelConfig<Context>;
public readonly $props: {[key: string]: Prop};
public static readonly $props: {[key: string]: PropConfig} = {};
public readonly __config: ModelConfig<Context>;
public readonly __props: {[key: string]: Prop};
public static readonly __props: {[key: string]: PropConfig} = {};

@@ -22,7 +22,7 @@ /**

Object.defineProperty(this, '$config', {
Object.defineProperty(this, '__config', {
value: config || {},
enumerable: false,
});
Object.defineProperty(this, '$props', {
Object.defineProperty(this, '__props', {
value: {},

@@ -41,3 +41,3 @@ enumerable: false,

protected defineProps() {
const recipes = this.constructor['$props'];
const recipes = this.constructor['__props'];

@@ -56,3 +56,3 @@ for (const key in recipes) {

this.$props[key] = new Prop({
this.__props[key] = new Prop({
...config,

@@ -63,4 +63,4 @@ model: this,

Object.defineProperty(this, key, {
get: () => this.$props[key].getValue(),
set: (value) => this.$props[key].setValue(value),
get: () => this.__props[key].getValue(),
set: (value) => this.__props[key].setValue(value),
enumerable: config.enumerable !== false,

@@ -75,3 +75,3 @@ configurable: false,

public getContext(): Context {
return realize(this.$config.context) || null;
return realize(this.__config.context) || null;
}

@@ -83,3 +83,3 @@

public getParent(): Model<Context> {
return this.$config.parent || null;
return this.__config.parent || null;
}

@@ -115,3 +115,3 @@

if (keys.length === 0) {
return this.$props[lastKey];
return this.__props[lastKey];
} else if (isInteger(lastKey)) {

@@ -141,3 +141,3 @@ lastKey = keys.pop(); // array items refer to parent prop

Object.keys(data || {}).forEach((key) => {
const prop = this.$props[key];
const prop = this.__props[key];
if (prop) {

@@ -158,4 +158,4 @@ prop.setValue(data[key], strategy);

Object.keys(this.$props).forEach((key) => {
const value = this.$props[key].serialize(strategy);
Object.keys(this.__props).forEach((key) => {
const value = this.__props[key].serialize(strategy);
if (!isUndefined(value)) {

@@ -205,4 +205,4 @@ data[key] = value;

Object.keys(this.$props)
.forEach((key) => this.$props[key].reset());
Object.keys(this.__props)
.forEach((key) => this.__props[key].reset());

@@ -217,4 +217,4 @@ return this;

Object.keys(this.$props)
.forEach((key) => this.$props[key].fake());
Object.keys(this.__props)
.forEach((key) => this.__props[key].fake());

@@ -229,4 +229,4 @@ return this;

Object.keys(this.$props)
.forEach((key) => this.$props[key].empty());
Object.keys(this.__props)
.forEach((key) => this.__props[key].empty());

@@ -241,4 +241,4 @@ return this;

Object.keys(this.$props)
.forEach((key) => this.$props[key].commit());
Object.keys(this.__props)
.forEach((key) => this.__props[key].commit());

@@ -253,4 +253,4 @@ return this;

Object.keys(this.$props)
.forEach((key) => this.$props[key].rollback());
Object.keys(this.__props)
.forEach((key) => this.__props[key].rollback());

@@ -265,4 +265,4 @@ return this;

Object.keys(this.$props)
.forEach((key) => this.$props[key].freeze());
Object.keys(this.__props)
.forEach((key) => this.__props[key].freeze());

@@ -288,4 +288,4 @@ return this;

public isChanged(): boolean {
return Object.keys(this.$props)
.some((key) => this.$props[key].isChanged());
return Object.keys(this.__props)
.some((key) => this.__props[key].isChanged());
}

@@ -297,4 +297,4 @@

public isValid(): boolean {
return !Object.keys(this.$props)
.some((key) => !this.$props[key].isValid());
return !Object.keys(this.__props)
.some((key) => !this.__props[key].isValid());
}

@@ -313,4 +313,4 @@

await Promise.all(
Object.keys(this.$props)
.map((key) => this.$props[key].validate())
Object.keys(this.__props)
.map((key) => this.__props[key].validate())
);

@@ -345,4 +345,4 @@

await Promise.all(
Object.keys(this.$props)
.map((n) => this.$props[n].handle(error))
Object.keys(this.__props)
.map((n) => this.__props[n].handle(error))
);

@@ -390,4 +390,4 @@

public invalidate(): this {
Object.keys(this.$props)
.forEach((key) => this.$props[key].invalidate());
Object.keys(this.__props)
.forEach((key) => this.__props[key].invalidate());

@@ -406,3 +406,3 @@ return this;

}, {
...this.$config,
...this.__config,
});

@@ -409,0 +409,0 @@ }

@@ -17,7 +17,7 @@ import { normalize, realize, isDeepEqual, isUndefined, isPresent, toArray,

if (target.constructor.prototype && target.constructor.prototype.constructor) {
other = { ...target.constructor.prototype.constructor.$props };
other = { ...target.constructor.prototype.constructor.__props };
}
other[key] = { ...config };
Object.defineProperty(target.constructor, '$props', {
Object.defineProperty(target.constructor, '__props', {
value: other,

@@ -39,3 +39,3 @@ enumerable: false,

protected _frozen: boolean = false;
public readonly $config: PropConfig;
public readonly __config: PropConfig;

@@ -48,3 +48,3 @@ /**

Object.defineProperty(this, '$config', {
Object.defineProperty(this, '__config', {
value: { ...config },

@@ -54,5 +54,5 @@ enumerable: false,

this._initialValue = this._rawValue = isUndefined(this.$config.defaultValue)
this._initialValue = this._rawValue = isUndefined(this.__config.defaultValue)
? null
: this.$config.defaultValue;
: this.__config.defaultValue;
}

@@ -64,3 +64,3 @@

public getModel() {
return realize(this.$config.model);
return realize(this.__config.model);
}

@@ -82,7 +82,7 @@

let value = isUndefined(data) ? null : data;
if (this.$config.parser) {
if (this.__config.parser) {
value = this.parse(realize(value, this.getModel()), strategy);
}
if (this.$config.setter) {
value = this.$config.setter.call(this.getModel(), realize(value, this.getModel()));
if (this.__config.setter) {
value = this.__config.setter.call(this.getModel(), realize(value, this.getModel()));
}

@@ -99,8 +99,8 @@

if (this.$config.getter) {
value = this.$config.getter.call(this.getModel(), value);
if (this.__config.getter) {
value = this.__config.getter.call(this.getModel(), value);
}
if (!isPresent(value) && !isUndefined(this.$config.emptyValue)) {
value = realize(this.$config.emptyValue, this.getModel());
if (!isPresent(value) && !isUndefined(this.__config.emptyValue)) {
value = realize(this.__config.emptyValue, this.getModel());
}

@@ -143,3 +143,3 @@

public isArray(): boolean {
const { array } = this.$config.parser || {} as any;
const { array } = this.__config.parser || {} as any;
return array === true;

@@ -154,6 +154,6 @@ }

return (
this.$config.enumerable !== false
this.__config.enumerable !== false
&& (
isUndefined(strategy)
|| (this.$config.populatable || []).indexOf(strategy) !== -1
|| (this.__config.populatable || []).indexOf(strategy) !== -1
)

@@ -169,6 +169,6 @@ );

return (
this.$config.enumerable !== false
this.__config.enumerable !== false
&& (
isUndefined(strategy)
|| (this.$config.serializable || []).indexOf(strategy) !== -1
|| (this.__config.serializable || []).indexOf(strategy) !== -1
)

@@ -238,3 +238,3 @@ );

protected parse(value: any, strategy?: string): any {
const parser = (this.$config.parser || {}) as any;
const parser = (this.__config.parser || {}) as any;
const recipe = {

@@ -256,3 +256,3 @@ resolver: parser.resolver,

return new Klass(null, {
...this.getModel().$config,
...this.getModel().__config,
parent: this.getModel(),

@@ -291,3 +291,3 @@ }).populate(data, strategy);

public reset(): this {
this.setValue(this.$config.defaultValue);
this.setValue(this.__config.defaultValue);

@@ -302,3 +302,3 @@ return this;

this.setValue(this.$config.fakeValue);
this.setValue(this.__config.fakeValue);

@@ -350,3 +350,3 @@ (toArray(this._rawValue) || []) // related fake values

if (this.$config.parser) {
if (this.__config.parser) {
value = this.parse(value);

@@ -381,3 +381,3 @@ }

this.getValue(),
this.$config.validators,
this.__config.validators,
{

@@ -404,3 +404,3 @@ context: this.getModel(),

error,
this.$config.handlers,
this.__config.handlers,
{

@@ -407,0 +407,0 @@ context: this.getModel(),

@@ -14,3 +14,3 @@ import { Spec } from '@hayspec/spec';

const descriptor = Object.getOwnPropertyDescriptor(user, 'name');
ctx.true(user.$props['name'] instanceof Prop);
ctx.true(user.__props['name'] instanceof Prop);
ctx.is(user.name, null);

@@ -17,0 +17,0 @@ ctx.is(typeof descriptor.get, 'function');

@@ -19,3 +19,3 @@ import { Spec } from '@hayspec/spec';

ctx.true(prop0.isValid());
prop0.$config.parser = { resolver: User }; // nested model type
prop0.__config.parser = { resolver: User }; // nested model type
user.getProp('name').setErrorCode(200); // nested model error

@@ -22,0 +22,0 @@ ctx.false(prop0.isValid());

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc