From 810f60a1082d933c2a176e3b9fc4353044e5d2e6 Mon Sep 17 00:00:00 2001 From: Joachim Viide Date: Thu, 29 Feb 2024 16:16:03 +0000 Subject: [PATCH] chore: add docstrings for Type and Optional --- src/index.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/index.ts b/src/index.ts index 1c43385..5a407a4 100644 --- a/src/index.ts +++ b/src/index.ts @@ -464,6 +464,9 @@ type ParseOptions = { mode: "passthrough" | "strict" | "strip"; }; +/** + * A base class for all concreate validators/parsers. + */ abstract class Type extends AbstractType { nullable(): Type { return union(nullSingleton, this); @@ -514,6 +517,13 @@ abstract class Type extends AbstractType { } } +/** + * A validator/parser marked as "optional", signifying that their value can + * be missing from the parsed object. + * + * As such optionals can only be used as property validators within + * object validators. + */ class Optional extends AbstractType { readonly name = "optional";