All Questions
Tagged with typescript validation
671
questions
0
votes
0
answers
46
views
Using zod form validation with radio button group that has no default checked value on first render
I have a simple form that I am using zod to validate. For simplicity let's say the form has exactly one user field for specifying a selection:
const FormSchema = z.object({
options: z.enum(["...
0
votes
0
answers
33
views
How to test a custom decorator with a validation pipe in Nest.js?
I've found this GitHub issue comment that has an interesting workaround for accessing a custom decorator through reflection, but the problem is that I'm trying to use it to test my use case which ...
0
votes
0
answers
16
views
Generate csv template with dropdown list in react
I want my users to be able to download a default spreadsheet file with some fields having drop-down values. I know how to do this with Excel/Google Sheets but I'm unable to do this programmatically ...
0
votes
0
answers
66
views
How to map validation errors to use exposed property names in NestJS DTOs?
I'm working on a NestJS project where I need to map validation errors to use the exposed property names defined in my DTOs. Below is my current setup:
DTO:
import { Expose } from 'class-transformer';
...
0
votes
1
answer
62
views
Binding number to input in Svelte and TypeScript
I have a form in svelte, using shadcn-svelte, and zod.
Relevant code snippets:
// schema.ts
const formSchema = z.object({
/* ... */
maxParticipants: z.number()
});
<!-- form.svelte -->
&...
1
vote
1
answer
40
views
Client-side validation error animation not resetting properly
I have implemented a form validation and error display system using TransitionGroup for animations. The issueVisible flag controls the visibility of the error message, and determineField() helps ...
0
votes
2
answers
64
views
Joi validation not working correctly Nodejs
I am trying to validate a schema. its not very complex. below is my code
Joi.object({
mobile: Joi.string()
.label('mobile')
.pattern(/^(\+)[1-9]\d{7,14}$/)
.messages({
'string....
-1
votes
0
answers
26
views
How to validate a field that depends on another field of the same schema in Zod
I have a situation where I need to validate a field based on a value of the same schema.
Here is a code snippet what should make my intention clear:
import { z } from "zod";
const ...
0
votes
1
answer
69
views
Is it possible to preprocess discriminator in zod discriminated union?
I need to coerce string formatted numbers to number before using a value in z.discriminatedUnion. Is this possible? Here is a simplified code snippet:
import { z } from "zod";
const ...
1
vote
1
answer
54
views
Angular Material UI - How to add onBlur validation for checkboxes/radio buttons?
I'm trying to create some simple checkboxes and radio buttons with Angular Material UI. The problem I'm having is getting the red outline onBlur effect when the field is required and the user doesn't ...
0
votes
1
answer
55
views
Is there a way in Python to validate return objects like in Typescript?
I am creating objects with complex structure with Python and I would like to have ability to validate them like in Typescript somehow before they are returned from function. Perfect option would be ...
0
votes
2
answers
69
views
TypeScript: How to validate input fields with form checkboxes
I have a form with several checkboxes and corresponding input fields.
<div class="group-wrap input-element" id="gr_">
<div class="label-bar">
<label&...
1
vote
1
answer
304
views
How to handle errors in Hono middleware when ID doesn't match regex pattern?
I'm currently working on a bun application using Hono. In one of my routes, I have a URL pattern defined using regex to match the date and title parameters. Here's an example of how it looks:
app.get('...
2
votes
1
answer
1k
views
How to Extend a Zod Object with Another Object and Pick Certain Entries?
I'm using Zod, a TypeScript schema validation library, to validate objects in my application. I have a scenario where I need to validate an object with nested properties and extend it with another ...
0
votes
1
answer
85
views
Email validation with angular material chips
I'm trying to create a form with an input using chips to send a message to various emails. I have it almost functional but I don't know how to properly show the message error when you write a invalid ...