mirror of
https://github.com/Crosstalk-Solutions/project-nomad.git
synced 2026-10-17 05:14:19 +02:00
Content Explorer hardcoded `lang: 'eng'`, so it could only ever show about 1,300 of the catalog's ~10,900 books. Adds a language selector sourced live from the catalog's own language feed, with book counts, defaulting to English and remembered per browser. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01F8Mgg1vd2eKSs8StZiuyMV
45 lines
1.0 KiB
TypeScript
45 lines
1.0 KiB
TypeScript
import vine from '@vinejs/vine'
|
|
|
|
export const listRemoteZimValidator = vine.compile(
|
|
vine.object({
|
|
start: vine.number().min(0).optional(),
|
|
count: vine.number().min(1).max(100).optional(),
|
|
query: vine.string().optional(),
|
|
// An ISO-639-3 code (`eng`, `fra`, `zho`) or the literal `all`. Constrained to a
|
|
// short alphabetic token so this can never smuggle anything else into the upstream
|
|
// catalog query string.
|
|
language: vine
|
|
.string()
|
|
.trim()
|
|
.regex(/^(all|[a-z]{2,8})$/)
|
|
.optional(),
|
|
})
|
|
)
|
|
|
|
export const addCustomLibraryValidator = vine.compile(
|
|
vine.object({
|
|
name: vine.string().trim().minLength(1).maxLength(100),
|
|
base_url: vine
|
|
.string()
|
|
.url({ require_tld: false })
|
|
.trim(),
|
|
})
|
|
)
|
|
|
|
export const browseLibraryValidator = vine.compile(
|
|
vine.object({
|
|
url: vine
|
|
.string()
|
|
.url({ require_tld: false })
|
|
.trim(),
|
|
})
|
|
)
|
|
|
|
export const idParamValidator = vine.compile(
|
|
vine.object({
|
|
params: vine.object({
|
|
id: vine.number(),
|
|
}),
|
|
})
|
|
)
|