🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

schema-typed

Package Overview
Dependencies
Maintainers
1
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

schema-typed - npm Package Compare versions

Comparing version

to
2.1.1

19

CHANGELOG.md

@@ -0,28 +1,23 @@

## [2.1.1](https://github.com/rsuite/schema-typed/compare/2.1.0...2.1.1) (2023-03-08)
- chore: change the compilation target of TypeScript from esnext to es2019
# [2.1.0](https://github.com/rsuite/schema-typed/compare/2.0.4...2.1.0) (2023-03-02)
### Features
* addAsyncRule to allow sync and async rules to run ([#63](https://github.com/rsuite/schema-typed/issues/63)) ([574f9ad](https://github.com/rsuite/schema-typed/commit/574f9ad973af97b8c1bae44c3fcfa3dad608c4d6))
- addAsyncRule to allow sync and async rules to run ([#63](https://github.com/rsuite/schema-typed/issues/63)) ([574f9ad](https://github.com/rsuite/schema-typed/commit/574f9ad973af97b8c1bae44c3fcfa3dad608c4d6))
## [2.0.4](https://github.com/rsuite/schema-typed/compare/2.0.3...2.0.4) (2023-03-01)
### Bug Fixes
* promises where not allowed by type ([#61](https://github.com/rsuite/schema-typed/issues/61)) ([9cc665c](https://github.com/rsuite/schema-typed/commit/9cc665c4f72b5a22942d351c961263c179888a7a))
- promises where not allowed by type ([#61](https://github.com/rsuite/schema-typed/issues/61)) ([9cc665c](https://github.com/rsuite/schema-typed/commit/9cc665c4f72b5a22942d351c961263c179888a7a))
## [2.0.3](https://github.com/rsuite/schema-typed/compare/2.0.2...2.0.3) (2022-06-30)
### Bug Fixes
* **ObjectType:** specifies type of property `object` in the `ObjectType` check result ([#46](https://github.com/rsuite/schema-typed/issues/46)) ([0571e09](https://github.com/rsuite/schema-typed/commit/0571e097217b0c999acaf9e5780bdd289aa46a46))
- **ObjectType:** specifies type of property `object` in the `ObjectType` check result ([#46](https://github.com/rsuite/schema-typed/issues/46)) ([0571e09](https://github.com/rsuite/schema-typed/commit/0571e097217b0c999acaf9e5780bdd289aa46a46))
# 2.0.2

@@ -29,0 +24,0 @@

@@ -59,3 +59,3 @@ import { MixedType } from './MixedType';

});
const hasError = !!checkResults.find(item => item?.hasError);
const hasError = !!checkResults.find(item => item === null || item === void 0 ? void 0 : item.hasError);
return {

@@ -62,0 +62,0 @@ hasError,

import { checkRequired, createValidator, createValidatorAsync, isEmpty, formatErrorMessage } from './utils';
import locales from './locales';
export class MixedType {
typeName;
required = false;
requiredMessage = '';
trim = false;
emptyAllowed = false;
rules = [];
priorityRules = [];
schemaSpec;
value;
locale;
constructor(name) {
this.required = false;
this.requiredMessage = '';
this.trim = false;
this.emptyAllowed = false;
this.rules = [];
this.priorityRules = [];
this.typeName = name;

@@ -67,2 +63,3 @@ this.locale = Object.assign(name ? locales[name] : {}, locales.mixed);

pushRule(rule) {
var _a, _b;
const { onValid, errorMessage, priority, params } = rule;

@@ -73,3 +70,3 @@ const nextRule = {

isAsync: rule.isAsync,
errorMessage: errorMessage || this.rules?.[0]?.errorMessage
errorMessage: errorMessage || ((_b = (_a = this.rules) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.errorMessage)
};

@@ -76,0 +73,0 @@ if (priority) {

import { MixedType } from './MixedType';
import { createValidator, createValidatorAsync, checkRequired, isEmpty } from './utils';
export class ObjectType extends MixedType {
objectTypeSchemaSpec;
constructor(errorMessage) {

@@ -22,3 +21,3 @@ super('object');

const checkResult = check(value[k], value, v);
if (checkResult?.hasError) {
if (checkResult === null || checkResult === void 0 ? void 0 : checkResult.hasError) {
hasError = true;

@@ -25,0 +24,0 @@ }

export class Schema {
spec;
data;
constructor(schema) {

@@ -8,3 +6,4 @@ this.spec = schema;

getFieldType(fieldName) {
return this.spec?.[fieldName];
var _a;
return (_a = this.spec) === null || _a === void 0 ? void 0 : _a[fieldName];
}

@@ -19,3 +18,3 @@ getKeys() {

Object.entries(this.spec).forEach(([key, type]) => {
type.setSchemaOptions(this.spec, data?.[key]);
type.setSchemaOptions(this.spec, data === null || data === void 0 ? void 0 : data[key]);
});

@@ -22,0 +21,0 @@ this.data = data;

@@ -26,3 +26,3 @@ import formatErrorMessage from './formatErrorMessage';

});
return Promise.all(promises).then(results => results.find((item) => item && item?.hasError));
return Promise.all(promises).then(results => results.find((item) => item && (item === null || item === void 0 ? void 0 : item.hasError)));
};

@@ -29,0 +29,0 @@ }

@@ -8,3 +8,3 @@ /**

return errorMessage.replace(/\$\{\s*(\w+)\s*\}/g, (_, key) => {
return params?.[key] || `[${key}]`;
return (params === null || params === void 0 ? void 0 : params[key]) || `[${key}]`;
});

@@ -11,0 +11,0 @@ }

{
"name": "schema-typed",
"version": "2.1.0",
"version": "2.1.1",
"description": "Schema for data modeling & validation",

@@ -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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet