@internal
(recur: (ast: AST) => SchemaParser.Parser)
| 2063 | * An `Objects` node with no properties and no index signatures performs only a |
| 2064 | * non-nullish check: it accepts any value except `null` and `undefined`, |
| 2065 | * including primitive values. |
| 2066 | * |
| 2067 | * **Gotchas** |
| 2068 | * |
| 2069 | * Duplicate property names throw at construction time. |
| 2070 | * |
| 2071 | * **Example** (Inspecting a struct AST) |
| 2072 | * |
| 2073 | * ```ts import.meta.vitest |
| 2074 | * import { Schema, SchemaAST } from "effect" |
| 2075 | * |
| 2076 | * const schema = Schema.Struct({ name: Schema.String }) |
| 2077 | * const ast = schema.ast |
| 2078 | * |
| 2079 | * if (SchemaAST.isObjects(ast)) { |
| 2080 | * ast.propertySignatures.map((ps) => [ps.name, ps.type._tag]) // => [["name", "String"]] |
| 2081 | * } |
| 2082 | * ``` |
| 2083 | * |
| 2084 | * @see {@link isObjects} |
| 2085 | * @see {@link PropertySignature} |
| 2086 | * @see {@link IndexSignature} |
| 2087 | * @see {@link Arrays} |
| 2088 | * @category models |
| 2089 | * @since 4.0.0 |
| 2090 | */ |
| 2091 | export class Objects extends Base { |
| 2092 | readonly _tag = "Objects" |
| 2093 | readonly propertySignatures: ReadonlyArray<PropertySignature> |
| 2094 | readonly indexSignatures: ReadonlyArray<IndexSignature> |
| 2095 | readonly encodingChecks: Checks | undefined |
| 2096 | |
| 2097 | constructor( |
| 2098 | propertySignatures: ReadonlyArray<PropertySignature>, |
| 2099 | indexSignatures: ReadonlyArray<IndexSignature>, |
| 2100 | annotations?: Schema.Annotations.Annotations, |
| 2101 | checks?: Checks, |
| 2102 | encoding?: Encoding, |
| 2103 | context?: Context, |
| 2104 | encodingChecks?: Checks |
| 2105 | ) { |
| 2106 | super(annotations, checks, encoding, context) |
| 2107 | this.propertySignatures = propertySignatures |
| 2108 | this.indexSignatures = indexSignatures |
| 2109 | this.encodingChecks = encodingChecks |
| 2110 | |
| 2111 | // Duplicate property signatures |
| 2112 | const duplicates = propertySignatures.map((ps) => ps.name).filter((name, i, arr) => arr.indexOf(name) !== i) |
| 2113 | if (duplicates.length > 0) { |
| 2114 | throw new Error(`Duplicate identifiers: ${JSON.stringify(duplicates)}. ts(2300)`) |
| 2115 | } |
| 2116 | } |
| 2117 | /** @internal */ |
| 2118 | getParser( |
| 2119 | compile: SchemaParser.Compiler, |
| 2120 | compileConstructorDefault: SchemaParser.Compiler = compile |
| 2121 | ): SchemaParser.Parser { |
| 2122 | // oxlint-disable-next-line @typescript-eslint/no-this-alias |
nothing calls this directly
no test coverage detected