Repository: pydantic/pydantic

Issue:
`RuntimeError: Unable to apply constraint strict to schema lax-or-strict` when trying to set strictness on enum fields
### Initial Checks

- [X] I confirm that I'm using Pydantic V2

### Description

To allow "enum matching" from json input, I depend on setting enum field validation to `strict=False`.

This worked fine with pydantic 2.1.0. 

Expectation would be that this works for enums. 😄 

Thanks for your great work.

### Example Code

```Python
import enum
from pydantic import BaseModel, ConfigDict, Field


class Demo(enum.Enum):
    A = 0
    B = 1


class User(BaseModel):
    model_config = ConfigDict(strict=True)
    name: str
    age: int = Field(strict=False)
    this_works: Demo
    this_does_not: Demo = Field(strict=False)  # comment this to make it work
```


### Python, Pydantic & OS Version

```Text
pydantic version: 2.4.2
        pydantic-core version: 2.10.1
          pydantic-core build: profile=release pgo=false
                 install path: C:\Users\UserName\AppData\Local\pypoetry\Cache\virtualenvs\package-name-oKTDepZE-py3.8\Lib\site-packages\pydantic
               python version: 3.8.10 (tags/v3.8.10:3d8993a, May  3 2021, 11:48:03) [MSC v.1928 64 bit (AMD64)]
                     platform: Windows-10-10.0.22621-SP0
             related packages: typing_extensions-4.8.0
```



Discussion:
Hi @lovetheguitar,

Thanks for reporting this! This does seem to be a bug 🐛. I'll look into a fix and keep you updated on this thread 👍.

Resolving patch:
diff --git a/pydantic/_internal/_known_annotated_metadata.py b/pydantic/_internal/_known_annotated_metadata.py
--- a/pydantic/_internal/_known_annotated_metadata.py
+++ b/pydantic/_internal/_known_annotated_metadata.py
@@ -37,6 +37,7 @@
 DATE_TIME_CONSTRAINTS = {*NUMERIC_CONSTRAINTS, *STRICT}
 TIMEDELTA_CONSTRAINTS = {*NUMERIC_CONSTRAINTS, *STRICT}
 TIME_CONSTRAINTS = {*NUMERIC_CONSTRAINTS, *STRICT}
+LAX_OR_STRICT_CONSTRAINTS = {*STRICT}
 
 UNION_CONSTRAINTS = {'union_mode'}
 URL_CONSTRAINTS = {
@@ -85,6 +86,8 @@
     CONSTRAINTS_TO_ALLOWED_SCHEMAS[constraint].update(('url', 'multi-host-url'))
 for constraint in BOOL_CONSTRAINTS:
     CONSTRAINTS_TO_ALLOWED_SCHEMAS[constraint].update(('bool',))
+for constraint in LAX_OR_STRICT_CONSTRAINTS:
+    CONSTRAINTS_TO_ALLOWED_SCHEMAS[constraint].update(('lax-or-strict',))
 
 
 def add_js_update_schema(s: cs.CoreSchema, f: Callable[[], dict[str, Any]]) -> None:


Test patch:
diff --git a/tests/test_types.py b/tests/test_types.py
--- a/tests/test_types.py
+++ b/tests/test_types.py
@@ -1700,6 +1700,28 @@ class Model(BaseModel):
         ]
 
 
+def test_strict_enum() -> None:
+    class Demo(Enum):
+        A = 0
+        B = 1
+
+    class User(BaseModel):
+        model_config = ConfigDict(strict=True)
+
+        demo_strict: Demo
+        demo_not_strict: Demo = Field(strict=False)
+
+    user = User(demo_strict=Demo.A, demo_not_strict=1)
+
+    assert isinstance(user.demo_strict, Demo)
+    assert isinstance(user.demo_not_strict, Demo)
+    assert user.demo_strict.value == 0
+    assert user.demo_not_strict.value == 1
+
+    with pytest.raises(ValidationError, match='Input should be an instance of test_strict_enum.<locals>.Demo'):
+        User(demo_strict=0, demo_not_strict=1)
+
+
 @pytest.mark.parametrize(
     'kwargs,type_',
     [