Skip to content

Commit

Permalink
fix: form error messages (#24)
Browse files Browse the repository at this point in the history
* fix: step component error

* fix form error messages
  • Loading branch information
ivopr authored Jun 12, 2023
1 parent c2ba2cf commit be95fa2
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,37 +7,37 @@ import { waterModels } from "@app/utils/water-models";
export const ACPYPEFormSchema = z.object({
// @ts-ignore
protein: z.custom<FileList>((v) => v[0] instanceof File, {
message: "forms:file-pdb.errors.no-pdb"
message: "simulations-form:file-pdb.errors.no-pdb"
}),
// @ts-ignore
ligandItp: z.custom<FileList>((v) => v[0] instanceof File, {
message: "forms:file-itp.errors.no-itp"
message: "simulations-form:file-itp.errors.no-itp"
}),
// @ts-ignore
ligandGro: z.custom<FileList>((v) => v[0] instanceof File, {
message: "forms:file-gro.errors.no-gro"
message: "simulations-form:file-gro.errors.no-gro"
}),
forceField: z.custom<keyof typeof acpypeForceFields>(
(v) => Object.keys(acpypeForceFields).includes(v as string),
{ message: "forms:force-field.errors.no-force-field" }
{ message: "simulations-form:force-field.errors.no-force-field" }
),
boxType: z.custom<keyof typeof boxTypes>(
(v) => Object.keys(boxTypes).includes(v as string),
{ message: "forms:box-type.errors.no-box-type" }
{ message: "simulations-form:box-type.errors.no-box-type" }
),
waterModel: z.custom<keyof typeof waterModels>(
(v) => Object.keys(waterModels).includes(v as string),
{ message: "forms:water-model.errors.no-water-model" }
{ message: "simulations-form:water-model.errors.no-water-model" }
),
boxDistance: z
.string()
.regex(
new RegExp("^\\d+(\\.\\d+)*$"),
"forms:box-distance.errors.distance-doesnt-match"
"simulations-form:box-distance.errors.distance-doesnt-match"
)
.refine(
(v) => Number(v) > 0 && Number(v) <= 1,
"forms:box-distance.errors.out-of-bounds"
"simulations-form:box-distance.errors.out-of-bounds"
),
neutralize: z.boolean().default(true),
ignore: z.boolean().default(true),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,29 @@ import { waterModels } from "@app/utils/water-models";
export const APOFormSchema = z.object({
// @ts-ignore
protein: z.custom<FileList>((v) => v[0] instanceof File, {
message: "forms:file-pdb.errors.no-pdb"
message: "simulations-form:file-pdb.errors.no-pdb"
}),
forceField: z.custom<keyof typeof apoForceFields>(
(v) => Object.keys(apoForceFields).includes(v as string),
{ message: "forms:force-field.errors.no-force-field" }
{ message: "simulations-form:force-field.errors.no-force-field" }
),
boxType: z.custom<keyof typeof boxTypes>(
(v) => Object.keys(boxTypes).includes(v as string),
{ message: "forms:box-type.errors.no-box-type" }
{ message: "simulations-form:box-type.errors.no-box-type" }
),
waterModel: z.custom<keyof typeof waterModels>(
(v) => Object.keys(waterModels).includes(v as string),
{ message: "forms:water-model.errors.no-water-model" }
{ message: "simulations-form:water-model.errors.no-water-model" }
),
boxDistance: z
.string()
.regex(
new RegExp("^\\d+(\\.\\d+)*$"),
"forms:box-distance.errors.distance-doesnt-match"
"simulations-form:box-distance.errors.distance-doesnt-match"
)
.refine(
(v) => Number(v) > 0 && Number(v) <= 1,
"forms:box-distance.errors.out-of-bounds"
"simulations-form:box-distance.errors.out-of-bounds"
),
neutralize: z.boolean().default(true),
ignore: z.boolean().default(true),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,37 +7,37 @@ import { waterModels } from "@app/utils/water-models";
export const PRODRGFormSchema = z.object({
// @ts-ignore
protein: z.custom<FileList>((v) => v[0] instanceof File, {
message: "forms:file-pdb.errors.no-pdb"
message: "simulations-form:file-pdb.errors.no-pdb"
}),
// @ts-ignore
ligandItp: z.custom<FileList>((v) => v[0] instanceof File, {
message: "forms:file-itp.errors.no-itp"
message: "simulations-form:file-itp.errors.no-itp"
}),
// @ts-ignore
ligandGro: z.custom<FileList>((v) => v[0] instanceof File, {
message: "forms:file-gro.errors.no-gro"
message: "simulations-form:file-gro.errors.no-gro"
}),
forceField: z.custom<keyof typeof prodrgForceFields>(
(v) => Object.keys(prodrgForceFields).includes(v as string),
{ message: "forms:force-field.errors.no-force-field" }
{ message: "simulations-form:force-field.errors.no-force-field" }
),
boxType: z.custom<keyof typeof boxTypes>(
(v) => Object.keys(boxTypes).includes(v as string),
{ message: "forms:box-type.errors.no-box-type" }
{ message: "simulations-form:box-type.errors.no-box-type" }
),
waterModel: z.custom<keyof typeof waterModels>(
(v) => Object.keys(waterModels).includes(v as string),
{ message: "forms:water-model.errors.no-water-model" }
{ message: "simulations-form:water-model.errors.no-water-model" }
),
boxDistance: z
.string()
.regex(
new RegExp("^\\d+(\\.\\d+)*$"),
"forms:box-distance.errors.distance-doesnt-match"
"simulations-form:box-distance.errors.distance-doesnt-match"
)
.refine(
(v) => Number(v) > 0 && Number(v) <= 1,
"forms:box-distance.errors.out-of-bounds"
"simulations-form:box-distance.errors.out-of-bounds"
),
neutralize: z.boolean().default(true),
ignore: z.boolean().default(true),
Expand Down

0 comments on commit be95fa2

Please sign in to comment.