fix(SW-188): more semantic name for tolang transformer function

This commit is contained in:
Chuma McPhoy
2024-08-14 10:01:04 +02:00
parent 400c0b48e4
commit 96d3f68ad3
2 changed files with 5 additions and 6 deletions

View File

@@ -1,6 +1,6 @@
import { z } from "zod"
import { fromUppercaseToLangEnum } from "@/server/utils"
import { toLang } from "@/server/utils"
const RatingsSchema = z
.object({
@@ -423,11 +423,11 @@ export const getHotelDataSchema = z.object({
type: z.string(), // No enum here but the standard return appears to be "hotels".
language: z
.string()
.refine((val) => fromUppercaseToLangEnum(val) !== undefined, {
.refine((val) => toLang(val) !== undefined, {
message: "Invalid language",
})
.transform((val) => {
const lang = fromUppercaseToLangEnum(val)
const lang = toLang(val)
if (!lang) {
throw new Error("Invalid language")
}