Alvi
Alvi14h ago

Can i reference a components table?

I am using a component plugin and want to use v.id("componentTableName") but the validator is not passing the value even if the value is valid
4 Replies
Convex Bot
Convex Bot14h ago
Thanks for posting in <#1088161997662724167>. Reminder: If you have a Convex Pro account, use the Convex Dashboard to file support tickets. - Provide context: What are you trying to achieve, what is the end-user interaction, what are you seeing? (full error message, command output, etc.) - Use search.convex.dev to search Docs, Stack, and Discord all at once. - Additionally, you can post your questions in the Convex Community's <#1228095053885476985> channel to receive a response from AI. - Avoid tagging staff unless specifically instructed. Thank you!
Sara
Sara14h ago
in the component itself, you'll be able to do this Within it's own schema, validators etc, but if you want to validate the app inside the app, or another component, just use v.string()
Alvi
AlviOP14h ago
thanks, but this way the validator is to permissive allowing every string value
Sara
Sara14h ago
You could validate the id inside the compoenent function by doing something like this if you want:
const id = ctx.db.normalizedId("someTable", unvalidatedId);
if(id===null) return("That's not a convex Id for someTable")
const id = ctx.db.normalizedId("someTable", unvalidatedId);
if(id===null) return("That's not a convex Id for someTable")
this doesn't check if the item exists, it just check if the type of Id is valid also see this https://discord.com/channels/1019350475847499849/1447698278538940627/1447848736343588985

Did you find this page helpful?