const require_rolldown_runtime = require('../../../../../../_virtual/rolldown_runtime.js');
const require_ValidationMetadata$1 = require('./metadata/ValidationMetadata.js');
const require_MetadataStorage$1 = require('./metadata/MetadataStorage.js');
const require_ValidationTypes$1 = require('./validation/ValidationTypes.js');
const require_container$1 = require('./container.js');
const require_ConstraintMetadata$1 = require('./metadata/ConstraintMetadata.js');

//#region ../../node_modules/.pnpm/class-validator@0.14.1/node_modules/class-validator/cjs/register-decorator.js
var require_register_decorator = /* @__PURE__ */ require_rolldown_runtime.__commonJS({ "../../node_modules/.pnpm/class-validator@0.14.1/node_modules/class-validator/cjs/register-decorator.js": ((exports) => {
	Object.defineProperty(exports, "__esModule", { value: true });
	const ConstraintMetadata_1 = require_ConstraintMetadata$1.require_ConstraintMetadata();
	const ValidationMetadata_1 = require_ValidationMetadata$1.require_ValidationMetadata();
	const ValidationTypes_1 = require_ValidationTypes$1.require_ValidationTypes();
	const container_1 = require_container$1.require_container();
	const MetadataStorage_1 = require_MetadataStorage$1.require_MetadataStorage();
	/**
	* Registers a custom validation decorator.
	*/
	function registerDecorator(options) {
		let constraintCls;
		if (options.validator instanceof Function) {
			constraintCls = options.validator;
			if ((0, container_1.getFromContainer)(MetadataStorage_1.MetadataStorage).getTargetValidatorConstraints(options.validator).length > 1) throw `More than one implementation of ValidatorConstraintInterface found for validator on: ${options.target.name}:${options.propertyName}`;
		} else {
			const validator = options.validator;
			constraintCls = class CustomConstraint {
				validate(value, validationArguments) {
					return validator.validate(value, validationArguments);
				}
				defaultMessage(validationArguments) {
					if (validator.defaultMessage) return validator.defaultMessage(validationArguments);
					return "";
				}
			};
			(0, MetadataStorage_1.getMetadataStorage)().addConstraintMetadata(new ConstraintMetadata_1.ConstraintMetadata(constraintCls, options.name, options.async));
		}
		const validationMetadataArgs = {
			type: options.name && ValidationTypes_1.ValidationTypes.isValid(options.name) ? options.name : ValidationTypes_1.ValidationTypes.CUSTOM_VALIDATION,
			name: options.name,
			target: options.target,
			propertyName: options.propertyName,
			validationOptions: options.options,
			constraintCls,
			constraints: options.constraints
		};
		(0, MetadataStorage_1.getMetadataStorage)().addValidationMetadata(new ValidationMetadata_1.ValidationMetadata(validationMetadataArgs));
	}
	exports.registerDecorator = registerDecorator;
}) });

//#endregion
Object.defineProperty(exports, 'default', {
  enumerable: true,
  get: function () {
    return require_register_decorator();
  }
});