(ast: AST): booleanReturns true if the AST node represents an optional property.
Details
Checks ast.context?.isOptional. Defaults to false when no
Context is set.
Source effect/SchemaAST.ts:33603 lines
export function function isOptional(ast: AST): booleanReturns true if the AST node represents an optional property.
Details
Checks ast.context?.isOptional. Defaults to false when no
Context
is set.
isOptional(ast: ASTast: type AST =
| Declaration
| Null
| Undefined
| Void
| Never
| Unknown
| Any
| String
| Number
| Boolean
| BigInt
| Symbol
| Literal
| UniqueSymbol
| ObjectKeyword
| Enum
| TemplateLiteral
| Arrays
| Objects
| Union<AST>
| Suspend
Discriminated union of all AST node types.
Details
Every Schema has an .ast property of this type. Use the guard functions
(
isString
,
isObjects
, etc.) to narrow to a specific variant,
then access variant-specific fields.
- All variants share the
Base
fields:
annotations, checks,
encoding, context.
- Discriminate on the
_tag field (e.g. "String", "Objects", "Union").
AST): boolean {
return ast: ASTast.Base.context: Context | undefinedcontext?.Context.isOptional: boolean | undefinedisOptional ?? false
}Referenced by 3 symbols