@openzeppelin/ui-utils 1.2.0 → 1.2.1

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.
package/dist/index.cjs CHANGED
@@ -1425,7 +1425,7 @@ function simpleHash(str) {
1425
1425
  * ```
1426
1426
  */
1427
1427
  function validateBytes(value, options = {}) {
1428
- const { acceptedFormats = "both", maxBytes, allowHexPrefix = true } = options;
1428
+ const { acceptedFormats = "both", maxBytes, exactBytes, allowHexPrefix = true } = options;
1429
1429
  if (!value || value.trim() === "") return {
1430
1430
  isValid: true,
1431
1431
  cleanedValue: "",
@@ -1487,6 +1487,13 @@ function validateBytes(value, options = {}) {
1487
1487
  cleanedValue: cleanValue,
1488
1488
  detectedFormat
1489
1489
  };
1490
+ if (exactBytes && byteSize !== exactBytes) return {
1491
+ isValid: false,
1492
+ error: `Exactly ${exactBytes} bytes required (${detectedFormat === "hex" ? `${exactBytes * 2} hex characters` : `${exactBytes} bytes`}), got ${byteSize} bytes`,
1493
+ cleanedValue: cleanValue,
1494
+ detectedFormat,
1495
+ byteSize
1496
+ };
1490
1497
  if (maxBytes && byteSize > maxBytes) return {
1491
1498
  isValid: false,
1492
1499
  error: `Maximum ${maxBytes} bytes allowed (${detectedFormat === "hex" ? `${maxBytes * 2} hex characters` : `${maxBytes} bytes`})`,