Skip to content

factory.makeTypeSchema does not respect @@strict #2873

Description

@sanny-io

Description and expected behavior
Line 471 unconditionally calls z.strictObject, but it is expected that the strictness should be respected.

Adjusting this behavior could be considered a breaking change.

makeTypeSchema<Type extends GetTypeDefs<Schema>>(
type: Type,
): z.ZodObject<GetTypeDefFieldsShape<Schema, Type>, z.core.$strict> {
const typeDef = this.schema.requireTypeDef(type);
const fields: Record<string, z.ZodType> = {};
for (const [fieldName, fieldDef] of Object.entries(typeDef.fields)) {
fields[fieldName] = this.applyDescription(this.makeScalarFieldSchema(fieldDef), fieldDef.attributes);
}
const shape = z.strictObject(fields);
return this.applyDescription(
addCustomValidation(shape, typeDef.attributes),
typeDef.attributes,
) as unknown as z.ZodObject<GetTypeDefFieldsShape<Schema, Type>, z.core.$strict>;
}

  • ZenStack version: 3.9.7

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions