Validation and uniqueness for reference id:s