Suite of AT Protocol TypeScript libraries built on web standards
21
fork

Configure Feed

Select the types of activity you want to include in your feed.

at main 24 lines 532 B view raw
1import { 2 Schema, 3 type ValidationResult, 4 type Validator, 5 type ValidatorContext, 6} from "../validation.ts"; 7 8export class OptionalSchema<T> extends Schema<T | undefined> { 9 declare readonly ["_lex"]: { output: T | undefined }; 10 11 constructor(readonly schema: Validator<T>) { 12 super(); 13 } 14 15 validateInContext( 16 input: unknown, 17 ctx: ValidatorContext, 18 ): ValidationResult<T | undefined> { 19 if (input === undefined) { 20 return ctx.success(undefined); 21 } 22 return ctx.validate(input, this.schema); 23 } 24}