UNPKG

@vecrea/oid4vc-prex

Version:

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

58 lines (57 loc) 1.69 kB
import { z } from 'zod'; /** * Zod schema for validating JSONPath values. * * This schema ensures that a JSONPath is a string starting with '$'. * It applies the following validations: * - The value must be a string. * - The string must start with '$'. * * @type {z.ZodString} * * @example * // Valid usage * jsonPathSchema.parse('$.abc123'); // Returns '$.abc123' * jsonPathSchema.parse('$[0]'); // Returns '$[0]' * * // Invalid usage (will throw ZodError) * jsonPathSchema.parse('abc123'); // Throws error: Invalid JSONPath * jsonPathSchema.parse(123); // Throws error: Expected string, received number * * @throws {z.ZodError} Throws a ZodError if the input fails validation */ export declare const jsonPathSchema: z.ZodEffects<z.ZodString, string, string>; /** * Represents a JSON Path. * * A JSON Path is a string that describes the path to a JSON value. * * @class * @example * // Create a valid JsonPath instance * const jsonPathValue = jsonPathSchema.parse('$.abc123'); */ export declare class JsonPath { value: string; /** * Creates an instance of JsonPath. * * @param {string} value The JSON Path value */ private constructor(); /** * Creates an instance of JsonPath from string. * * @param {string} value The JSON Path value * @returns {JsonPath | undefined} The JsonPath instance or undefined if the input is invalid. */ static fromString(s: string): JsonPath | undefined; /** * Returns the string representation of the JsonPath. * * This method is used for JSON serialization. * * @returns {string} The JSON Path value. */ toJSON(): string; }