Socket
Socket
Sign inDemoInstall

@altiore/form

Package Overview
Dependencies
7
Maintainers
1
Versions
180
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.3.37 to 0.3.38

10

dist/@common/types.d.ts

@@ -54,7 +54,5 @@ import { MouseEventHandler, MutableRefObject } from 'react';

}
export declare type ValidateFuncType = {
validate: (value: any, getFieldValueByName?: ((name: string) => any) | any) => {
error: Error;
value: any;
} | undefined | any;
};
export declare type ValidateFuncType = (value: any, getFieldValueByName?: ((name: string) => any) | any) => {
error: Error;
value: any;
} | undefined | any;

2

dist/create-field-array/named-field-array/validated-field-array/hooks/use-validate-list.js

@@ -11,3 +11,3 @@ import { useMemo } from 'react';

validators.forEach(function (validate) {
var result = validate.validate(items, DEF_GET_VALUE);
var result = validate(items, DEF_GET_VALUE);
if (result === null || result === void 0 ? void 0 : result.error) {

@@ -14,0 +14,0 @@ ers.push(result.error.message);

@@ -74,3 +74,3 @@ import { useCallback, useEffect, useMemo, useState, } from 'react';

validators.forEach(function (validate) {
var result = validate.validate(value_1, getFormValueByName);
var result = validate(value_1, getFormValueByName);
if (result === null || result === void 0 ? void 0 : result.error) {

@@ -77,0 +77,0 @@ errors_1.push(result.error.message);

@@ -24,4 +24,4 @@ import React from 'react';

React.createElement(Field, { label: "Title", name: "title" }),
React.createElement(FieldArray, { name: "ingredients", validators: [Joi.array().min(2)] }),
React.createElement(FieldArray, { name: "ingredients", validators: [Joi.array().min(2).validate] }),
React.createElement("button", { type: "submit" }, "Submit")));
};

@@ -23,3 +23,3 @@ import React from 'react';

'string.min': 'Слишком коротко',
}),
}).validate,
] }),

@@ -26,0 +26,0 @@ React.createElement(Field, { name: "second", label: "Second", defaultValue: 'test', validators: [minLength(3)] })));

export * from './max-length';
export * from './min-length';
export * from './regexp';
export * from './min-length';
export * from './max-length';
export * from './min-length';
export * from './regexp';
export * from './min-length';

@@ -1,3 +0,3 @@

export var maxLength = function (length) { return ({
validate: function (value) {
export var maxLength = function (length) {
return function (value) {
var stringedValue = value.toString();

@@ -14,3 +14,3 @@ if (length < 0) {

return undefined;
},
}); };
};
};
import { maxLength } from '..';
describe('maxLength()', function () {
it('Корретные значения', function () {
expect(maxLength(5).validate('norm')).toBeUndefined();
expect(maxLength(5)('norm')).toBeUndefined();
});
it('Некорректные данные', function () {
expect(maxLength(5).validate('text that more than 5 chars')).toEqual({
expect(maxLength(5)('text that more than 5 chars')).toEqual({
error: new Error('The length of the entered value should be no more than 5 characters'),

@@ -13,4 +13,4 @@ value: 'text that more than 5 chars',

it('Длина должна быть больше 0', function () {
expect(function () { return maxLength(-1).validate('the text doesnt matter'); }).toThrow("Param 'length' cannot be less than 0");
expect(function () { return maxLength(-1)('the text doesnt matter'); }).toThrow("Param 'length' cannot be less than 0");
});
});

@@ -1,3 +0,3 @@

export var minLength = function (length) { return ({
validate: function (value) {
export var minLength = function (length) {
return function (value) {
if (value === void 0) { value = ''; }

@@ -17,3 +17,3 @@ if (typeof (value === null || value === void 0 ? void 0 : value.length) !== 'number') {

return undefined;
},
}); };
};
};
import { minLength } from '..';
describe('minLength()', function () {
it('Некорректные данные, которые должны выдать ошибку пользователю', function () {
expect(minLength(15).validate('wrong text')).toEqual({
expect(minLength(15)('wrong text')).toEqual({
error: new Error('The length of the entered value should be more than 15 characters'),

@@ -10,7 +10,7 @@ value: 'wrong text',

it('Корректные данные', function () {
expect(minLength(5).validate('this is normal text')).toBeUndefined();
expect(minLength(5)('this is normal text')).toBeUndefined();
});
it('Длина не должна быть меньше 0', function () {
expect(function () { return minLength(-1).validate('the text doesnt matter'); }).toThrow("Param 'length' cannot be less than 0");
expect(function () { return minLength(-1)('the text doesnt matter'); }).toThrow("Param 'length' cannot be less than 0");
});
});

@@ -1,3 +0,3 @@

export var regexp = function (regex) { return ({
validate: function (value) {
export var regexp = function (regex) {
return function (value) {
var stringedValue = value.toString();

@@ -11,3 +11,3 @@ if (!regex.test(stringedValue)) {

return undefined;
},
}); };
};
};
import { regexp } from '..';
describe('regexp()', function () {
it('this values must throw error', function () {
expect(regexp(/\d+/).validate('wrong text')).toEqual({
expect(regexp(/\d+/)('wrong text')).toEqual({
error: new Error('wrong text does not fit the regular expression /\\d+/'),

@@ -10,4 +10,4 @@ value: 'wrong text',

it('this values must pass without any errors', function () {
expect(regexp(/^[a-zA-Z]+$/).validate('this')).toBeUndefined();
expect(regexp(/^[a-zA-Z]+$/)('this')).toBeUndefined();
});
});
{
"name": "@altiore/form",
"version": "0.3.37",
"version": "0.3.38",
"description": "Form helper for building powerful forms",

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

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