Socket
Socket
Sign inDemoInstall

schema-typed

Package Overview
Dependencies
2
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.2.0 to 2.2.1

9

CHANGELOG.md

@@ -0,1 +1,10 @@

## [2.2.1](https://github.com/rsuite/schema-typed/compare/2.2.0...2.2.1) (2024-04-12)
### Bug Fixes
* **ObjectType:** fix required message for properties not being replaced ([#79](https://github.com/rsuite/schema-typed/issues/79)) ([2aab276](https://github.com/rsuite/schema-typed/commit/2aab2768994b42d3572c2d90a926329912811c80))
# [2.2.0](https://github.com/rsuite/schema-typed/compare/2.1.3...2.2.0) (2024-04-11)

@@ -2,0 +11,0 @@

20

es/MixedType.js

@@ -49,5 +49,6 @@ import { checkRequired, createValidator, createValidatorAsync, isEmpty, shallowEqual, formatErrorMessage, get } from './utils';

const validator = createValidator(data, fieldName, this.fieldLabel);
const checkStatus = validator(value, this.priorityRules);
if (checkStatus) {
return checkStatus;
const checkResult = validator(value, this.priorityRules);
// If the priority rule fails, return the result directly
if (checkResult) {
return checkResult;
}

@@ -70,5 +71,6 @@ if (!this.required && isEmpty(value)) {

return new Promise(resolve => validator(value, this.priorityRules)
.then((checkStatus) => {
if (checkStatus) {
resolve(checkStatus);
.then((checkResult) => {
// If the priority rule fails, return the result directly
if (checkResult) {
resolve(checkResult);
}

@@ -82,5 +84,5 @@ })

.then(() => validator(value, this.rules))
.then((checkStatus) => {
if (checkStatus) {
resolve(checkStatus);
.then((checkResult) => {
if (checkResult) {
resolve(checkResult);
}

@@ -87,0 +89,0 @@ resolve({ hasError: false });

@@ -13,6 +13,7 @@ import { MixedType, schemaSpecKey } from './MixedType';

const check = (value, data, type, childFieldKey) => {
var _a;
if (type.required && !checkRequired(value, type.trim, type.emptyAllowed)) {
return {
hasError: true,
errorMessage: formatErrorMessage(this.requiredMessage || this.locale.isRequired, {
errorMessage: formatErrorMessage(type.requiredMessage || ((_a = type.locale) === null || _a === void 0 ? void 0 : _a.isRequired), {
name: type.fieldLabel || childFieldKey || fieldName

@@ -48,6 +49,7 @@ })

const check = (value, data, type, childFieldKey) => {
var _a;
if (type.required && !checkRequired(value, type.trim, type.emptyAllowed)) {
return Promise.resolve({
hasError: true,
errorMessage: formatErrorMessage(this.requiredMessage || this.locale.isRequired, {
errorMessage: formatErrorMessage(type.requiredMessage || ((_a = type.locale) === null || _a === void 0 ? void 0 : _a.isRequired), {
name: type.fieldLabel || childFieldKey || fieldName

@@ -54,0 +56,0 @@ })

@@ -29,2 +29,6 @@ import { SchemaDeclaration, SchemaCheckResult, CheckResult, PlainObject } from './types';

getKeys(): string[];
/**
* Get the schema specification
*/
getSchemaSpec(): SchemaDeclaration<DataType, ErrorMsgType>;
checkForField<T extends keyof DataType>(fieldName: T, data: DataType, options?: CheckOptions): CheckResult<ErrorMsgType | string>;

@@ -31,0 +35,0 @@ checkForFieldAsync<T extends keyof DataType>(fieldName: T, data: DataType, options?: CheckOptions): Promise<CheckResult<ErrorMsgType | string>>;

@@ -66,2 +66,8 @@ import { getFieldType, getFieldValue } from './MixedType';

}
/**
* Get the schema specification
*/
getSchemaSpec() {
return this.$spec;
}
checkForField(fieldName, data, options = {}) {

@@ -68,0 +74,0 @@ var _a;

@@ -57,5 +57,6 @@ "use strict";

const validator = (0, utils_1.createValidator)(data, fieldName, this.fieldLabel);
const checkStatus = validator(value, this.priorityRules);
if (checkStatus) {
return checkStatus;
const checkResult = validator(value, this.priorityRules);
// If the priority rule fails, return the result directly
if (checkResult) {
return checkResult;
}

@@ -78,5 +79,6 @@ if (!this.required && (0, utils_1.isEmpty)(value)) {

return new Promise(resolve => validator(value, this.priorityRules)
.then((checkStatus) => {
if (checkStatus) {
resolve(checkStatus);
.then((checkResult) => {
// If the priority rule fails, return the result directly
if (checkResult) {
resolve(checkResult);
}

@@ -90,5 +92,5 @@ })

.then(() => validator(value, this.rules))
.then((checkStatus) => {
if (checkStatus) {
resolve(checkStatus);
.then((checkResult) => {
if (checkResult) {
resolve(checkResult);
}

@@ -95,0 +97,0 @@ resolve({ hasError: false });

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

const check = (value, data, type, childFieldKey) => {
var _a;
if (type.required && !(0, utils_1.checkRequired)(value, type.trim, type.emptyAllowed)) {
return {
hasError: true,
errorMessage: (0, utils_1.formatErrorMessage)(this.requiredMessage || this.locale.isRequired, {
errorMessage: (0, utils_1.formatErrorMessage)(type.requiredMessage || ((_a = type.locale) === null || _a === void 0 ? void 0 : _a.isRequired), {
name: type.fieldLabel || childFieldKey || fieldName

@@ -51,6 +52,7 @@ })

const check = (value, data, type, childFieldKey) => {
var _a;
if (type.required && !(0, utils_1.checkRequired)(value, type.trim, type.emptyAllowed)) {
return Promise.resolve({
hasError: true,
errorMessage: (0, utils_1.formatErrorMessage)(this.requiredMessage || this.locale.isRequired, {
errorMessage: (0, utils_1.formatErrorMessage)(type.requiredMessage || ((_a = type.locale) === null || _a === void 0 ? void 0 : _a.isRequired), {
name: type.fieldLabel || childFieldKey || fieldName

@@ -57,0 +59,0 @@ })

@@ -29,2 +29,6 @@ import { SchemaDeclaration, SchemaCheckResult, CheckResult, PlainObject } from './types';

getKeys(): string[];
/**
* Get the schema specification
*/
getSchemaSpec(): SchemaDeclaration<DataType, ErrorMsgType>;
checkForField<T extends keyof DataType>(fieldName: T, data: DataType, options?: CheckOptions): CheckResult<ErrorMsgType | string>;

@@ -31,0 +35,0 @@ checkForFieldAsync<T extends keyof DataType>(fieldName: T, data: DataType, options?: CheckOptions): Promise<CheckResult<ErrorMsgType | string>>;

@@ -69,2 +69,8 @@ "use strict";

}
/**
* Get the schema specification
*/
getSchemaSpec() {
return this.$spec;
}
checkForField(fieldName, data, options = {}) {

@@ -71,0 +77,0 @@ var _a;

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

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -92,6 +92,7 @@ import {

const checkStatus = validator(value, this.priorityRules);
const checkResult = validator(value, this.priorityRules);
if (checkStatus) {
return checkStatus;
// If the priority rule fails, return the result directly
if (checkResult) {
return checkResult;
}

@@ -128,5 +129,6 @@

validator(value, this.priorityRules)
.then((checkStatus: CheckResult<E | string> | void | null) => {
if (checkStatus) {
resolve(checkStatus);
.then((checkResult: CheckResult<E | string> | void | null) => {
// If the priority rule fails, return the result directly
if (checkResult) {
resolve(checkResult);
}

@@ -140,5 +142,5 @@ })

.then(() => validator(value, this.rules))
.then((checkStatus: CheckResult<E | string> | void | null) => {
if (checkStatus) {
resolve(checkStatus);
.then((checkResult: CheckResult<E | string> | void | null) => {
if (checkResult) {
resolve(checkResult);
}

@@ -145,0 +147,0 @@ resolve({ hasError: false });

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

hasError: true,
errorMessage: formatErrorMessage<E>(this.requiredMessage || this.locale.isRequired, {
errorMessage: formatErrorMessage<E>(type.requiredMessage || type.locale?.isRequired, {
name: type.fieldLabel || childFieldKey || fieldName

@@ -79,3 +79,3 @@ })

hasError: true,
errorMessage: formatErrorMessage<E>(this.requiredMessage || this.locale.isRequired, {
errorMessage: formatErrorMessage<E>(type.requiredMessage || type.locale?.isRequired, {
name: type.fieldLabel || childFieldKey || fieldName

@@ -82,0 +82,0 @@ })

@@ -98,2 +98,9 @@ import { SchemaDeclaration, SchemaCheckResult, CheckResult, PlainObject } from './types';

/**
* Get the schema specification
*/
getSchemaSpec() {
return this.$spec;
}
checkForField<T extends keyof DataType>(

@@ -100,0 +107,0 @@ fieldName: T,

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