I'm creating a Postgres database with several tables. How can I limit the domain of fields? (like ensuring the 'humidity' field is between 0-100)

I came across these two docs on CONSTRAINTS and ENUMS in Postgres, and they look like they are exactly what I want.But has anyone figured out how to define tables in pure TypeScript so they can be strictly typed?

I attached a theoretical example of what I am talking about. The first image is SQL using CHECK, and the second is what I thought the TypeScript could look like.

It would be cool if I could write everything in TS, and it 'compiles' into whatever Postgres needs to create the tables.