def validate_value(self, value):
super(UserGroupField, self).validate_value(value)<EOL>if value is not None:<EOL><INDENT>if self._show_all_groups and self._show_all_users:<EOL><INDENT>return<EOL><DEDENT>if value.id in self._allowed_user_ids | self._allowed_group_ids:<EOL><INDENT>return<EOL><DEDENT>value = value.resolve()<EOL>if isinstance(value, User):<EOL><INDENT>self._validate_user(value)<EOL><DEDENT>else:<EOL><INDENT>self._validate_group(value)<EOL><DEDENT><DEDENT>
Validate new user/group value against any User/Group restrictions

        Attempts to resolve generic UserGroup instances if necessary to respect special "Everyone" group, and
        "All Users" + "All Groups" options