schema compile BUGFIX check all union values for a valid one

Instead of each of its type separately.
Fixes sysrepo/sysrepo#3028
diff --git a/src/schema_compile.c b/src/schema_compile.c
index d93f374..001a3af 100644
--- a/src/schema_compile.c
+++ b/src/schema_compile.c
@@ -815,6 +815,7 @@
     struct lysc_type **t;
     LY_ARRAY_COUNT_TYPE u, count;
     struct lysc_type_enum *ent;
+    ly_bool has_value = 0;
 
     if (leaf->type->basetype == LY_TYPE_UNION) {
         t = ((struct lysc_type_union *)leaf->type)->types;
@@ -829,14 +830,19 @@
             ent = (struct lysc_type_enum *)(t[u]);
             lys_compile_unres_disabled_bitenum_remove(&ctx->free_ctx, ent->enums);
 
-            if (!LY_ARRAY_COUNT(ent->enums)) {
-                LOGVAL(ctx->ctx, LYVE_SEMANTICS, "%s type of node \"%s\" without any (or all disabled) valid values.",
-                        (ent->basetype == LY_TYPE_BITS) ? "Bits" : "Enumeration", leaf->name);
-                return LY_EVALID;
+            if (LY_ARRAY_COUNT(ent->enums)) {
+                has_value = 1;
             }
+        } else {
+            has_value = 1;
         }
     }
 
+    if (!has_value) {
+        LOGVAL(ctx->ctx, LYVE_SEMANTICS, "Node \"%s\" without any (or all disabled) valid values.", leaf->name);
+        return LY_EVALID;
+    }
+
     return LY_SUCCESS;
 }
 
diff --git a/tests/utests/schema/test_schema.c b/tests/utests/schema/test_schema.c
index 18d61f0..1451d9d 100644
--- a/tests/utests/schema/test_schema.c
+++ b/tests/utests/schema/test_schema.c
@@ -1159,7 +1159,7 @@
             "}}"
             "}";
     assert_int_equal(lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL), LY_EVALID);
-    CHECK_LOG_CTX("Enumeration type of node \"l\" without any (or all disabled) valid values.", "Schema location \"/a:l\".");
+    CHECK_LOG_CTX("Node \"l\" without any (or all disabled) valid values.", "Schema location \"/a:l\".");
 
     /* disabled default value */
     str = "module a {"