Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions lib/components/resistor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
commonComponentProps,
lrPins,
} from "lib/common/layout"
import { footprintProp } from "lib/common/footprintProp"
import {
schematicSymbolSize,
type SchematicSymbolSize,
Expand Down Expand Up @@ -56,8 +57,9 @@ const mapResistorFootprint = (
if (!resistorImperialFootprintNames.has(footprint)) return footprint
return `res${footprint}`
}
export const resistorProps = commonComponentProps
.extend({
export const resistorProps: z.ZodType<ResistorProps> =
commonComponentProps.extend({
footprint: footprintProp.optional().transform(mapResistorFootprint),
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

refine only validates the value.
We needed to actually change the value from 0402 to res0402.
For rewriting the value, we should use transform??

resistance,
tolerance: z
.union([z.string(), z.number()])
Expand Down Expand Up @@ -89,10 +91,6 @@ export const resistorProps = commonComponentProps

connections: createConnectionsProp(resistorPinLabels).optional(),
})
.transform((props) => ({
...props,
footprint: mapResistorFootprint(props.footprint),
}))
export const resistorPins = lrPins

type InferredResistorProps = z.input<typeof resistorProps>
Expand Down
Loading