# off-topic


04/01/2022, 6:25 AM
Data validation is a topic that I keep coming back to when considering Supabase as a platform. How are people solving this today? Is the only current way to use db functions for validation?


04/01/2022, 11:52 AM
For validation which can be evaluated based on the data of a single table, you can use PostgreSQL check constraints:
You can probably also use the RLS, since RLS just requires a boolean variable to determine whether it's OK to write or NOT, and that boolean can be based on anything you need, not just auth info
finally, there is a PostgreSQL extension that allows the validaiton of JSON schema, so you can also use that if you need to validate a JSON request payload before inserting it in the DB:


04/01/2022, 1:53 PM
Thanks chipilov. Do you know if it's possible to apply a more complicated check, like regex in a constraint check? I often find myself making sure that ppl don't intentionally (or by accident) add something that might cause problems. "Always validate user input" comes to mind 🙂
Seems like it does. Sweet! Postgres keeps surprising me in a good way