Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

calidation

Package Overview
Dependencies
Maintainers
1
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

calidation - npm Package Compare versions

Comparing version 1.13.0 to 1.13.1

60

dist/Form.js

@@ -63,2 +63,3 @@ 'use strict';

config: {},
dirty: {},
errors: {},

@@ -94,2 +95,3 @@ fields: {},

var _this$state = _this.state,
dirty = _this$state.dirty,
errors = _this$state.errors,

@@ -100,8 +102,11 @@ fields = _this$state.fields;

_this.setState({
dirty: Object.keys(dirty).reduce(function (allDirty, field) {
return _extends({}, allDirty, _defineProperty({}, field, false));
}, {}),
errors: Object.keys(errors).reduce(function (allErrors, field) {
return _extends({}, allErrors, _defineProperty({}, field, null));
}, null),
}, {}),
fields: Object.keys(fields).reduce(function (allFields, field) {
return _extends({}, allFields, _defineProperty({}, field, (0, _utilities.getFirstDefinedValue)(_this.initialValues[field], '')));
}, null),
return _extends({}, allFields, _defineProperty({}, field, _this.initialValues[field]));
}, {}),
submitted: false

@@ -117,2 +122,3 @@ });

var _this$state2 = _this.state,
dirty = _this$state2.dirty,
errors = _this$state2.errors,

@@ -125,3 +131,3 @@ fields = _this$state2.fields;

_this.props.onSubmit({
dirty: (0, _utilities.areDirty)(_this.initialValues, fields),
dirty: dirty,
errors: errors,

@@ -136,7 +142,16 @@ fields: fields,

}, _this.setField = function (diff) {
var fields = _extends({}, _this.state.fields, diff);
var _this$state3 = _this.state,
config = _this$state3.config,
dirty = _this$state3.dirty,
fields = _this$state3.fields;
var allFields = _extends({}, fields, diff);
var areDirty = _extends({}, dirty, Object.keys(diff).reduce(function (allDirty, field) {
return _extends({}, allDirty, _defineProperty({}, field, dirty[field] || diff[field] !== _this.initialValues[field]));
}, {}));
_this.setState({
errors: _this.validate(fields, _this.state.config),
fields: fields,
dirty: areDirty,
errors: _this.validate(config, allFields, areDirty),
fields: allFields,
submitted: false

@@ -149,11 +164,11 @@ });

});
}, _this.validate = function (fields, config) {
return Object.entries(config).reduce(function (allErrors, _ref2) {
}, _this.validate = function (allConfig, allFields, areDirty) {
return Object.entries(allConfig).reduce(function (allErrors, _ref2) {
var _ref3 = _slicedToArray(_ref2, 2),
name = _ref3[0],
fieldConfig = _ref3[1];
fieldName = _ref3[0],
fieldValidators = _ref3[1];
return _extends({}, allErrors, _defineProperty({}, name, _this.validateField(fieldConfig, name, fields, allErrors)));
return _extends({}, allErrors, _defineProperty({}, fieldName, _this.validateField(fieldName, fieldValidators, allFields, allErrors, areDirty)));
}, {});
}, _this.validateField = function (fieldValidators, name, allFields, allErrors) {
}, _this.validateField = function (fieldName, fieldValidators, allFields, allErrors, areDirty) {
return Object.entries(fieldValidators).reduce(function (error, _ref4) {

@@ -175,3 +190,3 @@ var _ref5 = _slicedToArray(_ref4, 2),

errors: _extends({}, _this.state.errors, allErrors),
isDirty: allFields[name] !== _this.initialValues[name]
isDirty: areDirty[fieldName]
};

@@ -191,3 +206,3 @@

return validator(validatorConfig, context)(allFields[name]);
return validator(validatorConfig, context)(allFields[fieldName]);
}, null);

@@ -200,2 +215,5 @@ }, _this.registerSubComponent = function (subComponentConfig, transforms, initialValues) {

var config = _extends({}, prevState.config, subComponentConfig);
var dirty = _extends({}, prevState.dirty, Object.keys(subComponentConfig).reduce(function (allDirty, field) {
return _extends({}, allDirty, _defineProperty({}, field, false));
}, {}));
var fields = _extends({}, prevState.fields, initialValues);

@@ -205,4 +223,5 @@

config: config,
fields: fields,
errors: _this.validate(fields, config)
dirty: dirty,
errors: _this.validate(config, fields, dirty),
fields: fields
};

@@ -218,2 +237,3 @@ });

var config = (0, _utilities.removeFrom)(prevState.config)(keys);
var dirty = (0, _utilities.removeFrom)(prevState.dirty)(keys);
var fields = (0, _utilities.removeFrom)(prevState.fields)(keys);

@@ -223,3 +243,4 @@

config: config,
errors: _this.validate(fields, config),
dirty: dirty,
errors: _this.validate(config, fields, dirty),
fields: fields

@@ -240,2 +261,3 @@ };

var _state = this.state,
dirty = _state.dirty,
errors = _state.errors,

@@ -246,3 +268,3 @@ fields = _state.fields,

var formContext = {
dirty: (0, _utilities.areDirty)(this.initialValues, fields),
dirty: dirty,
errors: errors,

@@ -249,0 +271,0 @@ fields: fields,

@@ -7,18 +7,8 @@ "use strict";

var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
var areDirty = exports.areDirty = function areDirty(original, current) {
var keys = [].concat(_toConsumableArray(new Set([].concat(_toConsumableArray(Object.keys(original)), _toConsumableArray(Object.keys(current))))));
return keys.reduce(function (obj, key) {
return _extends({}, obj, _defineProperty({}, key, original[key] !== current[key]));
}, {});
};
var getFirstDefinedValue = exports.getFirstDefinedValue = function getFirstDefinedValue() {

@@ -25,0 +15,0 @@ for (var _len = arguments.length, values = Array(_len), _key = 0; _key < _len; _key++) {

{
"name": "calidation",
"version": "1.13.0",
"version": "1.13.1",
"description": "A red hot validation library for React",

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

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc