code: def validate(self, session):
          
  
          errors = []
          if not self.login:
              errors.append(u'login is required')
          else:
              other = User.by_login(session, self.login)
              if other and other.id != self.id:
                  errors.append(u'duplicate login %s' % self.login)
          if not self.password:
              errors.append(u'password is required')
          if not self.email:
              errors.append(u'email is required')
          elif not re_email.match(self.email):
              errors.append(u'%s is not a valid email' % self.email)
  
          if len(errors):
              raise ModelError(errors)
          return True
docs: Validate that the current user can be saved.
  
          :param session: SQLAlchemy session
          :type session: :class:`sqlalchemy.Session`
  
          :return: ``True``
          :rtype: bool
  
          :raise: :class:`pyshop.helpers.sqla.ModelError` if user is not valid