@coxy/react-validator 2.0.5 → 2.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -14,7 +14,7 @@ class ValidationFieldWrapper extends react_1.Component {
14
14
  }
15
15
  validate() {
16
16
  const props = this.props;
17
- const customError = props.customErrors.find((item) => item.id === props.id);
17
+ const customError = (props.customErrors || []).find((item) => item.id === props.id);
18
18
  if (customError) {
19
19
  return customError;
20
20
  }
@@ -33,6 +33,6 @@ class ValidationFieldWrapper extends react_1.Component {
33
33
  }
34
34
  }
35
35
  function ValidatorField(props) {
36
- return ((0, jsx_runtime_1.jsx)(context_1.Context.Consumer, { children: (data) => ((0, jsx_runtime_1.jsx)(ValidationFieldWrapper, Object.assign({}, props, { customErrors: data.customErrors, registerField: data.registerField, unregisterField: data.unregisterField }))) }));
36
+ return ((0, jsx_runtime_1.jsx)(context_1.Context.Consumer, { children: (data) => ((0, jsx_runtime_1.jsx)(ValidationFieldWrapper, Object.assign({}, props, { customErrors: data === null || data === void 0 ? void 0 : data.customErrors, registerField: data === null || data === void 0 ? void 0 : data.registerField, unregisterField: data === null || data === void 0 ? void 0 : data.unregisterField }))) }));
37
37
  }
38
38
  exports.ValidatorField = ValidatorField;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coxy/react-validator",
3
- "version": "2.0.5",
3
+ "version": "2.0.7",
4
4
  "description": "🚀 Simple validation form for React or NodeJS apps. useValidator are included ;)",
5
5
  "main": "./dist/index.js",
6
6
  "repository": {
@@ -31,7 +31,7 @@ class ValidationFieldWrapper extends Component<Props> {
31
31
 
32
32
  validate(): Validity {
33
33
  const props = this.props
34
- const customError = props.customErrors.find((item) => item.id === props.id)
34
+ const customError = (props.customErrors || []).find((item) => item.id === props.id)
35
35
  if (customError) {
36
36
  return customError
37
37
  }
@@ -58,9 +58,9 @@ export function ValidatorField(props: Omit<Props, 'registerField' | 'unregisterF
58
58
  {(data) => (
59
59
  <ValidationFieldWrapper
60
60
  {...props}
61
- customErrors={data.customErrors}
62
- registerField={data.registerField}
63
- unregisterField={data.unregisterField}
61
+ customErrors={data?.customErrors}
62
+ registerField={data?.registerField}
63
+ unregisterField={data?.unregisterField}
64
64
  />
65
65
  )}
66
66
  </Context.Consumer>