ThePndaXpres
ThePndaXpres5mo ago

arg validation error

There seems to be a mismatch between my argument and the validation structure I have setup. I am not sure what the difference is though there is the error: Value: "{"title":"Test Form!","questions":[{"question_text":"Name:","question_type":"text"},{"question_text":"Date:","question_type":"date"},{"question_text":"Favorite Animal","question_type":"multiple_choice","answer_choices":["Dog","Bird","Cat"]}]}" Validator: v.object({questions: v.array(v.object({answer_choices: v.optional(v.array(v.string())), question_text: v.string(), question_type: v.string()})), title: v.string()}) Here is my code: args: { jsonSchema: v.object({ name: v.string(), arguments: v.object({ title: v.string(), questions: v.array( v.object({ question_text: v.string(), question_type: v.string(), answer_choices: v.optional(v.array(v.string())), }) ), }), id: v.string(), }), }, Here is the argument passed in: { name: 'get_form_fields', arguments: '{"title":"Test Form!","questions":[{"question_text":"Name:","question_type":"text"},{"question_text":"Date:","question_type":"date"},{"question_text":"Favorite Animal","question_type":"multiple_choice","answer_choices":["Dog","Bird","Cat"]}]}', id: 'jd75rcvn2prw660as04ak1qzf970rrpd' }
3 Replies
Hmza
Hmza5mo ago
What your client side code look like that is passing this argument? Are you using something like JSON.stringify? It seems like the argument you are passing in is a string. It should not be a string
jamalsoueidan
jamalsoueidan5mo ago
debug args: v.any() in the same method console.log(args); go to the LOG in the dashboard, and check what you are getting!
ian
ian5mo ago
You can make a test function, grab the values you’re passing in, and bisect until you narrow it down. I agree it looks right 🤔

Did you find this page helpful?