Adding custom validation to core fields
Your best bet is going to be to write your own field type for this. You can extend one of the built-in field types if you want.

You would put your custom validation logic in your field type’s validate() method.