

const require_rolldown_runtime = require('../../../../_virtual/rolldown_runtime.js');
const require_JsonTransformer = require('../../../../utils/JsonTransformer.js');
const require_VerificationMethod = require('./VerificationMethod.js');
let class_transformer = require("class-transformer");
let class_validator = require("class-validator");

//#region src/modules/dids/domain/verificationMethod/VerificationMethodTransformer.ts
/**
* Checks if a given value is a real string.
*/
function IsStringOrVerificationMethod(validationOptions) {
	return (0, class_validator.ValidateBy)({
		name: "isStringOrVerificationMethod",
		validator: {
			validate: (value) => (0, class_validator.isString)(value) || (0, class_validator.isInstance)(value, require_VerificationMethod.VerificationMethod),
			defaultMessage: (0, class_validator.buildMessage)((eachPrefix) => `${eachPrefix}$property must be a string or instance of VerificationMethod`, validationOptions)
		}
	}, validationOptions);
}
/**
* Decorator that transforms authentication json to corresponding class instances
*
* @example
* class Example {
*   VerificationMethodTransformer()
*   private authentication: VerificationMethod
* }
*/
function VerificationMethodTransformer() {
	return (0, class_transformer.Transform)(({ value, type }) => {
		if (type === class_transformer.TransformationType.PLAIN_TO_CLASS) return value?.map((auth) => {
			if (typeof auth === "string") return String(auth);
			return require_JsonTransformer.JsonTransformer.fromJSON(auth, require_VerificationMethod.VerificationMethod);
		});
		if (type === class_transformer.TransformationType.CLASS_TO_PLAIN) return value?.map((auth) => typeof auth === "string" ? auth : require_JsonTransformer.JsonTransformer.toJSON(auth));
		return value;
	});
}

//#endregion
exports.IsStringOrVerificationMethod = IsStringOrVerificationMethod;
exports.VerificationMethodTransformer = VerificationMethodTransformer;