Normally, if you have complex validation constraints, you can use @api.constrains, but for simple cases, you can also use _sql_constraints with the CHECK option. Take a look at the following example. This prevents the user from adding books with no pages or a negative number of pages:
_sql_constraints = [
('positive_page', 'CHECK(pages>0)', 'No of pages must be positive')
]