How to evaluate valid dependencies between multiple columns

I am currently struggling with the implementation of expectation involving multiple columns within a record. say i have a table with 4 columns

columns names

  1. id
  2. title
  3. gender
  4. gendercode

i want to write the following dq check/expectation

if (
(title is [mr, dr, sir] and
gender is [male, m] and
gendercode is 1)
OR
(title is [mrs, dr, madam] and
gender is [female, f] and
gendercode is 0)

)

pass

else

fail