Skip to content

Commit a0936cd

Browse files
committed
switch defautl for supports_partial
1 parent e220710 commit a0936cd

File tree

13 files changed

+57
-19
lines changed

13 files changed

+57
-19
lines changed

src/validators/arguments.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,4 +381,8 @@ impl Validator for ArgumentsValidator {
381381
fn get_name(&self) -> &str {
382382
Self::EXPECTED_TYPE
383383
}
384+
385+
fn supports_partial(&self) -> bool {
386+
false
387+
}
384388
}

src/validators/dataclass.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,10 @@ impl Validator for DataclassArgsValidator {
431431
fn get_name(&self) -> &str {
432432
&self.validator_name
433433
}
434+
435+
fn supports_partial(&self) -> bool {
436+
false
437+
}
434438
}
435439

436440
#[derive(Debug)]

src/validators/definitions.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,10 @@ impl Validator for DefinitionRefValidator {
109109
fn get_name(&self) -> &str {
110110
self.definition.get_or_init_name(|v| v.get_name().into())
111111
}
112+
113+
fn supports_partial(&self) -> bool {
114+
false
115+
}
112116
}
113117

114118
fn py_identity(obj: &Bound<'_, PyAny>) -> usize {

src/validators/dict.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,6 @@ impl Validator for DictValidator {
8787
fn get_name(&self) -> &str {
8888
&self.name
8989
}
90-
91-
fn supports_partial(&self) -> bool {
92-
true
93-
}
9490
}
9591

9692
struct ValidateToDict<'a, 's, 'py, I: Input<'py> + ?Sized> {

src/validators/frozenset.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,6 @@ impl Validator for FrozenSetValidator {
5252
fn get_name(&self) -> &str {
5353
&self.name
5454
}
55-
56-
fn supports_partial(&self) -> bool {
57-
true
58-
}
5955
}
6056

6157
struct ValidateToFrozenSet<'a, 's, 'py, I: Input<'py> + ?Sized> {

src/validators/generator.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,10 @@ impl Validator for GeneratorValidator {
9292
fn get_name(&self) -> &str {
9393
&self.name
9494
}
95+
96+
fn supports_partial(&self) -> bool {
97+
false
98+
}
9599
}
96100

97101
#[pyclass(module = "pydantic_core._pydantic_core")]

src/validators/json.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ impl Validator for JsonValidator {
6060
let json_bytes = json_either_bytes.as_slice();
6161
match self.validator {
6262
Some(ref validator) => {
63-
let json_value = JsonValue::parse(json_bytes, true).map_err(|e| map_json_err(input, e, json_bytes))?;
63+
let json_value = JsonValue::parse_with_config(json_bytes, true, state.allow_partial)
64+
.map_err(|e| map_json_err(input, e, json_bytes))?;
6465
let mut json_state = state.rebind_extra(|e| {
6566
e.input_type = InputType::Json;
6667
});

src/validators/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -803,8 +803,8 @@ pub trait Validator: Send + Sync + Debug {
803803
fn get_name(&self) -> &str;
804804

805805
/// Whether this validator supports partial validation, `state.allow_partial` should only be set to true
806-
/// if this is the case.
806+
/// when calling a validator if this is `true`.
807807
fn supports_partial(&self) -> bool {
808-
false
808+
true
809809
}
810810
}

src/validators/model_fields.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,4 +438,8 @@ impl Validator for ModelFieldsValidator {
438438
fn get_name(&self) -> &str {
439439
Self::EXPECTED_TYPE
440440
}
441+
442+
fn supports_partial(&self) -> bool {
443+
false
444+
}
441445
}

src/validators/set.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,6 @@ impl Validator for SetValidator {
8383
fn get_name(&self) -> &str {
8484
&self.name
8585
}
86-
87-
fn supports_partial(&self) -> bool {
88-
true
89-
}
9086
}
9187

9288
struct ValidateToSet<'a, 's, 'py, I: Input<'py> + ?Sized> {

0 commit comments

Comments
 (0)