-
| 
         Hi, I've a component as shown below, i'm trying to return the value of  const schema = z.object({
	customerId: z.number({ required_error: "Customer is required." }),
	amount: z.number({ required_error: "Amount is required." }),
});
type FormType = z.infer<typeof schema>;
export const AddDailyCollection = () => {
	const { control, handleSubmit,  } = useForm<FormType>({
		resolver: zodResolver(schema),
	});
	const userId = useUser.use.id();
	if (!userId) return;
	const { data } = useAssignedCustomer({ variables: { userId } });
	const onSubmit = (data: FormType) => {
		console.log(data);
	};
	return (
		<View className="flex-1 p-4">
			<ControlledSelect
				name="customerId"
				label="Customer"
				placeholder="Select a customer"
				control={control}
				options={data?.map(({ id, name, phone }) => ({
					label: `${name} - ${phone}`,
					value: id,
				}))}
			/>
			<ControlledInput name="amount" label="Amount" control={control}  />
			<View>
				<Button label="Save" onPress={handleSubmit(onSubmit)} />
			</View>
		</View>
	);
};I tried removing   | 
  
Beta Was this translation helpful? Give feedback.
      
      
          Answered by
          
            premdasvm
          
      
      
        Oct 25, 2023 
      
    
    Replies: 1 comment 3 replies
-
        const schema = z.object({
customerId: z.number({ required_error: "Customer is required." }),
amount: z
	.string()
	.refine(value => /^\d+$/.test(value), { message: "Amount must be a valid number." }),
});
const onSubmit = ({ customerId, amount }: FormType) => {
	console.log({ customerId, amount: Number(amount) });
};this is how i'm handling it as of now. Let me know if there is a better way for this.  | 
  
Beta Was this translation helpful? Give feedback.
                  
                    3 replies
                  
                
            
      Answer selected by
        yjose
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
        
    
this is how i'm handling it as of now. Let me know if there is a better way for this.