I have the following Postgres Table
column_a | column_b  | 
---------+-----------+
 001     | 1         | 
 004     | 2         | 
 006     | 3         | 
 007     | 4         | 
 008     | 5         | 
 104     | 0         | 
 204     | 0         |
I want to add a constraint to this table such that whenever (RIGHT(column_a, 1) = '4' OR column_a = '006') AND column_a <> '004' the value of column_b needs to be equal to 0. If that's not the case, I want to throw an error.
How can I do this?
Thanks!

006 | 3is an error?006 | 3is an error. Basically I want all values ofcolumn_bto be 0 when the right-most digit ofcolumn_ais 0. The exceptions to this are whencolumn_a = '004'then it does not have to be the case thatcolumn_bis 0. Also whencolumn_a = '006'then I need it to be 0