-
Notifications
You must be signed in to change notification settings - Fork 4
Fix blank string validation #491
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -3,18 +3,19 @@ import z from "zod" | |||||||||||||||||||||
| export const FormSchema = z.object({ | ||||||||||||||||||||||
| b_name: z | ||||||||||||||||||||||
| .string({ | ||||||||||||||||||||||
| required_error: "Naam van perceel is verplicht", | ||||||||||||||||||||||
| error: "Naam van perceel is verplicht", | ||||||||||||||||||||||
| }) | ||||||||||||||||||||||
| .trim() | ||||||||||||||||||||||
| .min(3, { | ||||||||||||||||||||||
| message: "Naam van perceel moet minimaal 3 karakters bevatten", | ||||||||||||||||||||||
| }), | ||||||||||||||||||||||
| b_area: z.coerce | ||||||||||||||||||||||
| .number({ | ||||||||||||||||||||||
| required_error: "Oppervlakte van perceel is verplicht", | ||||||||||||||||||||||
| error: "Oppervlakte van perceel is verplicht", | ||||||||||||||||||||||
| }) | ||||||||||||||||||||||
| .optional(), | ||||||||||||||||||||||
| b_lu_catalogue: z.string({ | ||||||||||||||||||||||
| required_error: "Hoofdgewas is verplicht", | ||||||||||||||||||||||
| error: "Hoofdgewas is verplicht", | ||||||||||||||||||||||
| }), | ||||||||||||||||||||||
|
Comment on lines
17
to
19
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Line 17–19 currently only enforces string type. Add trim + non-empty validation to fully align with this PR’s blank-string objective. Proposed fix- b_lu_catalogue: z.string({
- error: "Hoofdgewas is verplicht",
- }),
+ b_lu_catalogue: z
+ .string({
+ error: "Hoofdgewas is verplicht",
+ })
+ .trim()
+ .min(1, "Hoofdgewas is verplicht"),📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||
| b_bufferstrip: z.boolean().optional(), | ||||||||||||||||||||||
| }) | ||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: nmi-agro/fdm
Length of output: 209
🏁 Script executed:
# Get the file size first to understand what we're dealing with wc -l fdm-app/app/components/blocks/fields-new/schema.tsxRepository: nmi-agro/fdm
Length of output: 110
🏁 Script executed:
Repository: nmi-agro/fdm
Length of output: 734
🏁 Script executed:
Repository: nmi-agro/fdm
Length of output: 90
🏁 Script executed:
Repository: nmi-agro/fdm
Length of output: 8696
🏁 Script executed:
# Check the field/schema.tsx to see how optional numeric fields are handled there cat -n fdm-app/app/components/blocks/field/schema.tsxRepository: nmi-agro/fdm
Length of output: 1316
🏁 Script executed:
Repository: nmi-agro/fdm
Length of output: 2111
Add empty-string normalization to
b_areafield to match the established pattern for optional numeric fields.The
b_areafield should preprocess empty input toundefinedbefore numeric coercion, consistent with how other optional numeric fields are handled throughout the codebase (e.g.,b_lu_yieldin harvest schema). Without this, empty strings may be coerced improperly.Proposed fix
📝 Committable suggestion
🤖 Prompt for AI Agents