@bombillazo/rhf-plus 7.62.0-plus.1 → 7.62.0-plus.2

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.
@@ -1 +1 @@
1
- {"version":3,"file":"getValidateError.d.ts","sourceRoot":"","sources":["../../src/logic/getValidateError.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,GAAG,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAIhE,MAAM,CAAC,OAAO,UAAU,gBAAgB,CACtC,MAAM,EAAE,cAAc,EACtB,GAAG,EAAE,GAAG,EACR,IAAI,SAAa,GAChB,UAAU,GAAG,IAAI,CAYnB"}
1
+ {"version":3,"file":"getValidateError.d.ts","sourceRoot":"","sources":["../../src/logic/getValidateError.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAW,GAAG,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAIzE,MAAM,CAAC,OAAO,UAAU,gBAAgB,CACtC,MAAM,EAAE,cAAc,EACtB,GAAG,EAAE,GAAG,EACR,IAAI,SAAa,GAChB,UAAU,GAAG,IAAI,CAYnB"}
@@ -1,5 +1,5 @@
1
1
  import type { ValidationRule } from '../types';
2
- declare const _default: (validationData?: ValidationRule) => {
2
+ declare const _default: (validationData?: ValidationRule) => import("../types").ValidationValueMessage<import("../types").ValidationValue> | {
3
3
  value: string | number | boolean | RegExp | undefined;
4
4
  message: string;
5
5
  };
@@ -1,4 +1,4 @@
1
1
  import type { Field } from '../types';
2
- declare const _default: (options: Field["_f"]) => string | number | boolean | import("../types").ValidationValueMessage<boolean> | import("../types").ValidationValueMessage<string | number> | import("../types").ValidationRule<RegExp> | import("../types").Validate<any, import("../types").FieldValues> | Record<string, import("../types").Validate<any, import("../types").FieldValues>> | undefined;
2
+ declare const _default: (options: Field["_f"]) => string | number | boolean | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | import("../types").ValidationValueMessage<boolean> | import("../types").ValidationValueMessage<string | number> | import("../types").ValidationRule<RegExp> | import("../types").Validate<any, import("../types").FieldValues> | Record<string, import("../types").Validate<any, import("../types").FieldValues>> | undefined;
3
3
  export default _default;
4
4
  //# sourceMappingURL=hasValidation.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"validateField.d.ts","sourceRoot":"","sources":["../../src/logic/validateField.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,KAAK,EAEL,WAAW,EACX,mBAAmB,EACnB,eAAe,EAKhB,MAAM,UAAU,CAAC;yBAsBI,CAAC,SAAS,WAAW,EACzC,OAAO,KAAK,EACZ,oBAAoB,eAAe,EACnC,YAAY,CAAC,EACb,0BAA0B,OAAO,EACjC,4BAA4B,OAAO,EACnC,eAAe,OAAO,KACrB,OAAO,CAAC,mBAAmB,CAAC;AAP/B,wBA6PE"}
1
+ {"version":3,"file":"validateField.d.ts","sourceRoot":"","sources":["../../src/logic/validateField.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,KAAK,EAEL,WAAW,EACX,mBAAmB,EACnB,eAAe,EAKhB,MAAM,UAAU,CAAC;yBAsBI,CAAC,SAAS,WAAW,EACzC,OAAO,KAAK,EACZ,oBAAoB,eAAe,EACnC,YAAY,CAAC,EACb,0BAA0B,OAAO,EACjC,4BAA4B,OAAO,EACnC,eAAe,OAAO,KACrB,OAAO,CAAC,mBAAmB,CAAC;AAP/B,wBAoQE"}
@@ -1,4 +1,5 @@
1
1
  import crypto from 'crypto';
2
+ import React from 'react';
2
3
 
3
4
  var appendErrors = (name, validateAllFieldCriteria, errors, type, message) => validateAllFieldCriteria
4
5
  ? {
@@ -601,7 +602,17 @@ var updateFieldArrayRootError = (errors, error, name) => {
601
602
  return errors;
602
603
  };
603
604
 
604
- var isMessage = (value) => isString(value);
605
+ var isMessage = (value) => {
606
+ // Support strings (existing functionality)
607
+ if (isString(value)) {
608
+ return true;
609
+ }
610
+ // Support React elements only (not primitives like null, undefined, numbers)
611
+ if (React.isValidElement(value)) {
612
+ return true;
613
+ }
614
+ return false;
615
+ };
605
616
 
606
617
  function getValidateError(result, ref, type = 'validate') {
607
618
  if (isMessage(result) ||
@@ -631,7 +642,16 @@ var validateField = async (field, disabledFieldNames, formValues, validateAllFie
631
642
  const inputRef = refs ? refs[0] : ref;
632
643
  const setCustomValidity = (message) => {
633
644
  if (shouldUseNativeValidation && inputRef.reportValidity) {
634
- inputRef.setCustomValidity(isBoolean(message) ? '' : message || '');
645
+ if (isBoolean(message)) {
646
+ inputRef.setCustomValidity('');
647
+ }
648
+ else if (typeof message === 'string') {
649
+ inputRef.setCustomValidity(message || '');
650
+ }
651
+ else {
652
+ // For ReactNode messages, convert to string or use empty string for native validation
653
+ inputRef.setCustomValidity('');
654
+ }
635
655
  inputRef.reportValidity();
636
656
  }
637
657
  };