Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added male and female flag to pinrow footprint #204

Merged
merged 5 commits into from
Feb 20, 2025

Conversation

AnasSarkiz
Copy link
Member

/claim #202

@AnasSarkiz AnasSarkiz requested a review from seveibar February 18, 2025 22:25
Copy link
Contributor

@seveibar seveibar left a comment

Choose a reason for hiding this comment

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

See comment

@AnasSarkiz AnasSarkiz requested a review from seveibar February 19, 2025 17:25
@AnasSarkiz
Copy link
Member Author

@seveibar added error message if both male and female are true

export const pinrow_def = z
  .object({
    fn: z.string(),
    num_pins: z.number().optional().default(6),
    p: length.default("0.1in").describe("pitch"),
    id: length.default("1.0mm").describe("inner diameter"),
    od: length.default("1.5mm").describe("outer diameter"),
    male: z.boolean().optional().describe("for male pin headers"),
    female: z.boolean().optional().describe("for female pin headers"),
  })
  .transform((data) => ({
    ...data,
    male: data.male ?? (data.female ? false : true), // Auto-set male if not explicitly provided
    female: data.female ?? false, // Default female to false if not provided
  }))
  .superRefine((data, ctx) => {
    if (data.male && data.female) {
      ctx.addIssue({
        code: z.ZodIssueCode.custom,
        message:
          "'male' and 'female' cannot both be true it should be male or female.", //Error message if male and female are both true
        path: ["male", "female"],
      })
    }
  })

@AnasSarkiz
Copy link
Member Author

@seveibar can u check the latest commit

@seveibar seveibar merged commit 51408c6 into tscircuit:main Feb 20, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants