How to Validate Child Object Virtual Attribute against Parent Object Field?

Ok, I have the following:

Account => has_many => Users
Users => belong_to => Account

When an Account is created, an 'account_code' is also generated and
stored within the Accounts table. Users must use this 'account_code'
in order to Signup for the service. My problem is how do I compare
the User submitted 'account_code' in the Signup form against the
'account_code' stored in the parent object Account? Do I define this
'account_code' as a virtual attribute to the User model? Also, once I
make the comparison, in case there is a mismatch, how do I add the
error along with all other errors relating to User model?