def validate_roles_or_groups_present(self, data, **kwargs):
        """
        Ensure at least one of 'roles' or 'groups' is present and non-empty.
        """
        roles = data.get("roles") or []
        groups = data.get("groups") or []

        if not roles and not groups:
            raise ValidationError(
                "At least one of 'roles' or 'groups' must be provided and non-empty."
            )

        Ensure at least one of 'roles' or 'groups' is present and non-empty.
        
flask_appbuilder/security/sqla/apis/user/schema.py