@vecrea/oid4vc-prex
Version:
A TypeScript library for handling OpenID for Verifiable Credentials (OID4VC) Presentation Exchange operations
51 lines (50 loc) • 1.29 kB
TypeScript
import { z } from 'zod';
/**
* Zod schema for validating id values.
*
* This schema ensures that a id 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
* idSchema.parse('abc123'); // Returns 'abc123'
* idSchema.parse('a'); // Returns 'a'
*
* // Invalid usage (will throw ZodError)
* idSchema.parse(''); // Throws error: String must contain at least 1 character(s)
* idSchema.parse(123); // Throws error: Expected string, received number
*
* @throws {z.ZodError} Throws a ZodError if the input fails validation
*/
export declare const idSchema: z.ZodString;
/**
* Represents a id.
*
* @class
* @example
* // Create a valid Id instance
* const validId = new Id('abc123');
* console.log(validId.value); // Outputs: 'abc123'
*
*/
export declare class Id {
value: string;
/**
* Creates an instance of Id.
*
* @param {string} value - The value of the id.
*/
constructor(value: string);
/**
* Returns the string representation of the Id.
*
* This method is used for JSON serialization.
*
* @returns {string} The id value.
*/
toJSON(): string;
}