@nori-zk/proof-conversion
Version:
Verifying zkVM proofs inside o1js circuits, to generate Mina compatible proof
21 lines (20 loc) • 824 B
TypeScript
import { type ValidatorFn } from './core.js';
/**
* Factory function that creates a type guard validator for optional fields.
* Returns a ValidatorFn that narrows the type to `T | undefined` on success.
*
* The returned validator accepts either the validated type T or `undefined`.
* Useful for optional fields in schemas.
*
* @param validatorFunction - The validator for the non-undefined case
* @returns ValidatorFn<T | undefined> - Validator function with union type predicate
*
* @example
* const isOptionalString = isOptionalField(isString);
* // Returns: (val: unknown) => val is string | undefined
*
* if (isOptionalString(value)) {
* // value is narrowed to type: string | undefined
* }
*/
export declare function isOptionalField<T>(validatorFunction: ValidatorFn<T>): ValidatorFn<T | undefined>;