schema compile UPDATE allow deviate-replace implicit properties

Fixes #2212
diff --git a/src/schema_compile_amend.c b/src/schema_compile_amend.c
index 5f1a561..321ff94 100644
--- a/src/schema_compile_amend.c
+++ b/src/schema_compile_amend.c
@@ -4,7 +4,7 @@
  * @author Michal Vasko <mvasko@cesnet.cz>
  * @brief Schema compilation of augments, deviations, and refines.
  *
- * Copyright (c) 2015 - 2021 CESNET, z.s.p.o.
+ * Copyright (c) 2015 - 2024 CESNET, z.s.p.o.
  *
  * This source code is licensed under BSD 3-Clause License (the "License").
  * You may not use this file except in compliance with the License.
@@ -1499,13 +1499,6 @@
             AMEND_WRONG_NODETYPE("deviation", "replace", "mandatory");
         }
 
-        if (!(target->flags & LYS_MAND_MASK)) {
-            LOGVAL(ctx->ctx, LY_VCODE_DEV_NOT_PRESENT, "replacing", "mandatory",
-                    d->flags & LYS_MAND_TRUE ? "mandatory true" : "mandatory false");
-            ret = LY_EVALID;
-            goto cleanup;
-        }
-
         target->flags &= ~LYS_MAND_MASK;
         target->flags |= d->flags & LYS_MAND_MASK;
     }
@@ -1523,12 +1516,6 @@
             AMEND_WRONG_NODETYPE("deviation", "replace", "min-elements");
         }
 
-        if (!(target->flags & LYS_SET_MIN)) {
-            LOGVAL(ctx->ctx, LYVE_REFERENCE, "Invalid deviation replacing \"min-elements\" property which is not present.");
-            ret = LY_EVALID;
-            goto cleanup;
-        }
-
         *num = d->min;
     }
 
@@ -1545,12 +1532,6 @@
             AMEND_WRONG_NODETYPE("deviation", "replace", "max-elements");
         }
 
-        if (!(target->flags & LYS_SET_MAX)) {
-            LOGVAL(ctx->ctx, LYVE_REFERENCE, "Invalid deviation replacing \"max-elements\" property which is not present.");
-            ret = LY_EVALID;
-            goto cleanup;
-        }
-
         *num = d->max;
     }
 
diff --git a/tests/utests/schema/test_tree_schema_compile.c b/tests/utests/schema/test_tree_schema_compile.c
index f626360..6b4eadd 100644
--- a/tests/utests/schema/test_tree_schema_compile.c
+++ b/tests/utests/schema/test_tree_schema_compile.c
@@ -3607,10 +3607,6 @@
             "deviation /top {deviate replace {mandatory true;}}}", LYS_IN_YANG, &mod));
     CHECK_LOG_CTX("Invalid deviation of container node - it is not possible to replace \"mandatory\" property.",
             "/kk2:{deviation='/top'}", 0);
-    assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module kk3 {namespace urn:kk3;prefix kk3; container top {leaf x {type string;}}"
-            "deviation /top/x {deviate replace {mandatory true;}}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Invalid deviation replacing \"mandatory\" property \"mandatory true\" which is not present.",
-            "/kk3:{deviation='/top/x'}", 0);
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module kk4 {namespace urn:kk4;prefix kk4; leaf x {mandatory true; type string;}"
             "deviation /x {deviate add {mandatory false;}}}", LYS_IN_YANG, &mod));
     CHECK_LOG_CTX("Invalid deviation adding \"mandatory\" property which already exists (with value \"mandatory true\").",
@@ -3661,18 +3657,6 @@
             "deviation /x {deviate add {max-elements 1;}}}", LYS_IN_YANG, &mod));
     CHECK_LOG_CTX("Invalid deviation adding \"max-elements\" property which already exists (with value \"5\").",
             "/mm8:{deviation='/x'}", 0);
-    assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module mm9 {namespace urn:mm9;prefix mm9; leaf-list x {type string;}"
-            "deviation /x {deviate replace {min-elements 1;}}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Invalid deviation replacing \"min-elements\" property which is not present.", "/mm9:{deviation='/x'}", 0);
-    assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module mm10 {namespace urn:mm10;prefix mm10; list x {config false;}"
-            "deviation /x {deviate replace {min-elements 1;}}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Invalid deviation replacing \"min-elements\" property which is not present.", "/mm10:{deviation='/x'}", 0);
-    assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module mm11 {namespace urn:mm11;prefix mm11; leaf-list x {type string;}"
-            "deviation /x {deviate replace {max-elements 1;}}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Invalid deviation replacing \"max-elements\" property which is not present.", "/mm11:{deviation='/x'}", 0);
-    assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module mm12 {namespace urn:mm12;prefix mm12; list x {config false; }"
-            "deviation /x {deviate replace {max-elements 1;}}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Invalid deviation replacing \"max-elements\" property which is not present.", "/mm12:{deviation='/x'}", 0);
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module nn1 {namespace urn:nn1;prefix nn1; anyxml x;"
             "deviation /x {deviate replace {type string;}}}", LYS_IN_YANG, &mod));