easy-react-form
Advanced tools
Comparing version 2.0.7 to 2.0.8
<!-- pass through `required` property even when the field is not empty: maybe add some `passThroughRequiredWhenNotEmpty` configuration option. --> | ||
2.0.8 / 17.02.2023 | ||
================== | ||
* Removed the second argument of the `validate()` function — the argument that contained all form values. | ||
2.0.7 / 12.02.2023 | ||
@@ -4,0 +9,0 @@ ================== |
@@ -99,3 +99,4 @@ "use strict"; | ||
onBlur = _this$props3.onBlur; | ||
var error = _this.validate(context.state.values[_this.getName()]); | ||
var value = context.state.values[_this.getName()]; | ||
var error = _this.validate(value); | ||
// The `error` was `undefined` while the field was focused. | ||
@@ -157,12 +158,15 @@ if (error) { | ||
if (validate) { | ||
// `context.state.values` could be replaced with | ||
// something else, like `context.getValues()` | ||
// because `<List/>` values are prefixed in `context.state.values`. | ||
// But running RegExps and re-creating the object | ||
// on each `validate()` call seems like a not-the-best architecture. | ||
// Instead `values` could be replaced with something like | ||
// `context.getValues()` but that would be a "breaking change" in the API. | ||
// On a modern CPU a single `context.getValues()` run is about 0.005 ms. | ||
// So I guess it's acceptable, since the API already exists. | ||
return validate(value, context.getValues()); | ||
// // `context.state.values` could be replaced with | ||
// // something else, like `context.getValues()` | ||
// // because `<List/>` values are prefixed in `context.state.values`. | ||
// // But running RegExps and re-creating the object | ||
// // on each `validate()` call seems like a not-the-best architecture. | ||
// // Instead `values` could be replaced with something like | ||
// // `context.getValues()` but that would be a "breaking change" in the API. | ||
// // On a modern CPU a single `context.getValues()` run is about 0.005 ms. | ||
// // So I guess it's acceptable, since the API already exists. | ||
// const allValues = context.getValues() | ||
// return validate(value, allValues) | ||
return validate(value); | ||
} | ||
@@ -169,0 +173,0 @@ } |
@@ -92,3 +92,4 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } | ||
onBlur = _this$props3.onBlur; | ||
var error = _this.validate(context.state.values[_this.getName()]); | ||
var value = context.state.values[_this.getName()]; | ||
var error = _this.validate(value); | ||
// The `error` was `undefined` while the field was focused. | ||
@@ -150,12 +151,15 @@ if (error) { | ||
if (validate) { | ||
// `context.state.values` could be replaced with | ||
// something else, like `context.getValues()` | ||
// because `<List/>` values are prefixed in `context.state.values`. | ||
// But running RegExps and re-creating the object | ||
// on each `validate()` call seems like a not-the-best architecture. | ||
// Instead `values` could be replaced with something like | ||
// `context.getValues()` but that would be a "breaking change" in the API. | ||
// On a modern CPU a single `context.getValues()` run is about 0.005 ms. | ||
// So I guess it's acceptable, since the API already exists. | ||
return validate(value, context.getValues()); | ||
// // `context.state.values` could be replaced with | ||
// // something else, like `context.getValues()` | ||
// // because `<List/>` values are prefixed in `context.state.values`. | ||
// // But running RegExps and re-creating the object | ||
// // on each `validate()` call seems like a not-the-best architecture. | ||
// // Instead `values` could be replaced with something like | ||
// // `context.getValues()` but that would be a "breaking change" in the API. | ||
// // On a modern CPU a single `context.getValues()` run is about 0.005 ms. | ||
// // So I guess it's acceptable, since the API already exists. | ||
// const allValues = context.getValues() | ||
// return validate(value, allValues) | ||
return validate(value); | ||
} | ||
@@ -162,0 +166,0 @@ } |
{ | ||
"name": "easy-react-form", | ||
"version": "2.0.7", | ||
"version": "2.0.8", | ||
"description": "Simple, fast and easy-to-use React Form.", | ||
@@ -5,0 +5,0 @@ "main": "index.commonjs.js", |
@@ -193,3 +193,3 @@ # easy-react-form | ||
* `validate(value, allFormValues) : String` — Form field value validation function. Is only called when `value` is not "empty": `null` / `undefined` / `""` / `[]`. Should return an error message if the field value is invalid. | ||
* `validate(value) : String?` — Form field value validation function. Is only called when `value` is not "empty": `null` / `undefined` / `""` / `[]`. Should return an error message if the field value is invalid. | ||
@@ -196,0 +196,0 @@ * `required : String or Boolean` — adds "this field is required" validation for the `<Field/>` with the `error` message equal to `required` property value if it's a `String` defaulting to `"Required"` otherwise. Note that `value={false}` is valid in case of `required` because `false` is a non-empty value (e.g. "Yes"/"No" dropdown), therefore use `validate` function instead of `required` for checkboxes that are required to be checked, otherwise an unchecked checkbox will have `value={false}` and will pass the `required` check. |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
466281
4446