Fix bug when validating the uniqueness of an aliased attribute.

When validating the uniqueness of an aliased attribute, it was raising an error. To fix that, we have to check if the record being validated is an aliased attribute.

Closes #12402

/cc @rafaelfranca