UNPKG

@vecrea/oid4vc-prex

Version:

A TypeScript library for handling OpenID for Verifiable Credentials (OID4VC) Presentation Exchange operations

53 lines (52 loc) 1.44 kB
import { z } from 'zod'; /** * Zod schema for validating purpose values. * * This schema ensures that a purpose is a non-empty string. * It applies the following validations: * - The value must be a string. * - The string must have a minimum length of 1 character. * * @type {z.ZodString} * * @example * // Valid usage * purposeSchema.parse('abc123'); // Returns 'abc123' * purposeSchema.parse('a'); // Returns 'a' * * // Invalid usage (will throw ZodError) * purposeSchema.parse(''); // Throws error: String must contain at least 1 character(s) * purposeSchema.parse(123); // Throws error: Expected string, received number * * @throws {z.ZodError} Throws a ZodError if the input fails validation */ export declare const purposeSchema: z.ZodString; /** * Represents a purpose. * * A purpose is a value that describes the reason for the object's existence. * * @class * @example * // Create a Purpose instance * const purpose = new Purpose('abc123'); * console.log(purpose.value); // Outputs: 'abc123' * */ export declare class Purpose { value: string; /** * Creates an instance of Purpose. * * @param {string} value - The value of the purpose. */ constructor(value: string); /** * Returns the string representation of the Purpose. * * This method is used for JSON serialization. * * @returns {string} The purpose value. */ toJSON(): string; }