Files
pc_builder/app/validators/Components/store.ts
T
Kevin L'Hereec 4174d92711
Build & Deploy / build (push) Failing after 4s
Build & Deploy / docker (push) Skipped
feat: track purchase site URL for new components
- New nullable purchase_url column on components
- Store/update validators accept an optional purchaseUrl (must be a valid
  absolute URL with a protocol when provided)
- components/create.vue: NewPartSearch import now also fills purchaseUrl
  from the scraped part's source URL (pc-builder.io product page); the
  field remains manually editable for second-hand parts entered by hand
- components/edit.vue: purchaseUrl is editable after creation
- components/show.vue: displays the purchase site as a clickable link
  when present
- 4 new functional tests: create with/without a purchase URL, invalid URL
  rejected (asserts the Inertia inputErrorsBag flash, not a raw 422 -
  content negotiation only returns JSON for XHR/API-style requests), and
  updating an existing component's purchase URL
2026-07-23 14:10:54 +02:00

19 lines
536 B
TypeScript

import vine from '@vinejs/vine'
export const storeComponentValidator = vine.compile(
vine.object({
name: vine.string().trim().minLength(1),
price: vine.number().decimal([0, 2]).min(0),
typeId: vine.number().min(1),
purchaseDate: vine.string().regex(/^\d{4}-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])$/),
purchaseUrl: vine
.string()
.trim()
.url({ require_protocol: true })
.maxLength(2048)
.nullable()
.optional(),
quantity: vine.number().min(1).withoutDecimals(),
})
)