Skip to content

Commit

Permalink
chore: add docstrings for Type and Optional
Browse files Browse the repository at this point in the history
  • Loading branch information
jviide committed Feb 29, 2024
1 parent c9c50f3 commit 810f60a
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,9 @@ type ParseOptions = {
mode: "passthrough" | "strict" | "strip";
};

/**
* A base class for all concreate validators/parsers.
*/
abstract class Type<Output = unknown> extends AbstractType<Output> {
nullable(): Type<null | Output> {
return union(nullSingleton, this);
Expand Down Expand Up @@ -514,6 +517,13 @@ abstract class Type<Output = unknown> extends AbstractType<Output> {
}
}

/**
* 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<Output = unknown> extends AbstractType<Output | undefined> {
readonly name = "optional";

Expand Down

0 comments on commit 810f60a

Please sign in to comment.