"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var ValidationError_exports = {};
__export(ValidationError_exports, {
  ValidationDatatypeMismatchError: () => ValidationDatatypeMismatchError,
  ValidationError: () => ValidationError,
  ValidationMandatoryFieldMissingError: () => ValidationMandatoryFieldMissingError,
  ValidationOutOfBoundsError: () => ValidationOutOfBoundsError,
  validatorOf: () => validatorOf
});
module.exports = __toCommonJS(ValidationError_exports);
var import_Status = require("#globals/Status.js");
var import_StatusResponseError = require("./StatusResponseError.js");
/**
 * @license
 * Copyright 2022-2026 Matter.js Authors
 * SPDX-License-Identifier: Apache-2.0
 */
class ValidationError extends import_StatusResponseError.StatusResponseError {
  constructor(message, fieldName, errorCode = import_Status.Status.ConstraintError) {
    super(message, errorCode);
    this.fieldName = fieldName;
    this.message = `(${this.constructor.name}/${this.code}) ${message}`;
  }
}
class ValidationOutOfBoundsError extends ValidationError {
}
class ValidationDatatypeMismatchError extends ValidationError {
  constructor(message, fieldName) {
    super(message, fieldName, import_Status.Status.InvalidAction);
  }
}
class ValidationMandatoryFieldMissingError extends ValidationError {
  constructor(message, fieldName) {
    super(message, fieldName, import_Status.Status.InvalidAction);
  }
}
function validatorOf(test) {
  return (...a) => {
    try {
      test(...a);
      return true;
    } catch (e) {
      ValidationError.accept(e);
      return false;
    }
  };
}
//# sourceMappingURL=ValidationError.js.map
