<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def validate_username(self, data, value):
 """ Ensure the username is unique If the login is being created then simply check if the username is in the store & fail. Otherwise if the login is being updated check if the existing rid on a username match is the same as the login being updated otherwise fail. """


        store = goldman.sess.store
        existing = store.find(data['rtype'], 'username', value)

        if existing:
            if not data['rid'] or data['rid'] != existing.rid:
                raise ValidationError('username is already taken')