

const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.js');
const require_types = require('../../types.js');
const require_constants = require('./constants.js');
let class_validator = require("class-validator");

//#region src/modules/vc/validators.ts
function IsCredentialJsonLdContext(validationOptions) {
	const allowString = validationOptions?.allowString ?? false;
	const credentialContext = validationOptions?.credentialContext ?? require_constants.CREDENTIALS_CONTEXT_V1_URL;
	return (0, class_validator.ValidateBy)({
		name: "IsCredentialJsonLdContext",
		validator: {
			validate: (value) => {
				if (!Array.isArray(value)) return allowString && (0, class_validator.isString)(value) && value === credentialContext;
				if (value[0] !== credentialContext) return false;
				return value.every((v) => (0, class_validator.isString)(v) && (0, class_validator.isURL)(v) || require_types.isJsonObject(v));
			},
			defaultMessage: (0, class_validator.buildMessage)((eachPrefix) => `${eachPrefix}$property must be an array of strings or objects, where the first item is the verifiable credential context URL.`, validationOptions)
		}
	}, validationOptions);
}
function IsCredentialType(validationOptions) {
	return (0, class_validator.ValidateBy)({
		name: "IsVerifiableCredentialType",
		validator: {
			validate: (value) => {
				return Array.isArray(value) ? value.includes(require_constants.VERIFIABLE_CREDENTIAL_TYPE) && value.every((v) => typeof v === "string") : value === require_constants.VERIFIABLE_CREDENTIAL_TYPE;
			},
			defaultMessage: (0, class_validator.buildMessage)((eachPrefix) => `${eachPrefix}$property must be "VerifiableCredential" or an array of strings which includes "VerifiableCredential"`, validationOptions)
		}
	}, validationOptions);
}
function IsVerifiablePresentationType(validationOptions) {
	return (0, class_validator.ValidateBy)({
		name: "IsVerifiablePresentationType",
		validator: {
			validate: (value) => {
				return Array.isArray(value) ? value.includes(require_constants.VERIFIABLE_PRESENTATION_TYPE) && value.every((v) => typeof v === "string") : value === require_constants.VERIFIABLE_PRESENTATION_TYPE;
			},
			defaultMessage: (0, class_validator.buildMessage)((eachPrefix) => `${eachPrefix}$property must be "VerifiablePresentation" or an array of strings which includes "VerifiablePresentation"`, validationOptions)
		}
	}, validationOptions);
}

//#endregion
exports.IsCredentialJsonLdContext = IsCredentialJsonLdContext;
exports.IsCredentialType = IsCredentialType;
exports.IsVerifiablePresentationType = IsVerifiablePresentationType;