@@ -348,6 +348,16 @@ pub fn build_validator<'a>(
348
348
let schema: & PyDict = schema. downcast ( ) ?;
349
349
let type_: & str = schema. get_as_req ( intern ! ( schema. py( ) , "type" ) ) ?;
350
350
let val = match type_ {
351
+ // The left hand side of this match is a 1:1 match with the `type` field we use as a discriminator
352
+ // in our CoreSchema union
353
+ // The right hand side is _generally_ a 1:1 match but there are cases where we use a `Builder`
354
+ // on the right that may have internal logic to return different validators or just build a
355
+ // a more complex validator (e.g. building a union of isinstance validators or something).
356
+ // So to get from Python -> Rust implementation you should trace the `type` on the left hand side
357
+ // of the match and then if the right hand side is a `{Type}Validator` you've found the implementation.
358
+ // If the right hand side is a `{Type}Builder` you'll have to look into it's `build()` method to see
359
+ // what it actually returns.
360
+ // TODO: sort alphabetically? By left hand side string or right hand side type? Or RHS type's module filename?
351
361
"any" => build_specific_validator :: < any:: AnyValidator > ( schema, type_, config, build_context) ?,
352
362
"none" => build_specific_validator :: < none:: NoneValidator > ( schema, type_, config, build_context) ?,
353
363
"bool" => build_specific_validator :: < bool:: BoolValidator > ( schema, type_, config, build_context) ?,
@@ -379,15 +389,17 @@ pub fn build_validator<'a>(
379
389
"generator" => build_specific_validator :: < generator:: GeneratorValidator > ( schema, type_, config, build_context) ?,
380
390
"dict" => build_specific_validator :: < dict:: DictValidator > ( schema, type_, config, build_context) ?,
381
391
"function-plain" => {
382
- build_specific_validator :: < function:: FunctionBuilder > ( schema, type_, config, build_context) ?
392
+ build_specific_validator :: < function:: FunctionPlainValidator > ( schema, type_, config, build_context) ?
383
393
}
384
394
"function-before" => {
385
- build_specific_validator :: < function:: FunctionBuilder > ( schema, type_, config, build_context) ?
395
+ build_specific_validator :: < function:: FunctionBeforeValidator > ( schema, type_, config, build_context) ?
386
396
}
387
397
"function-after" => {
388
- build_specific_validator :: < function:: FunctionBuilder > ( schema, type_, config, build_context) ?
398
+ build_specific_validator :: < function:: FunctionAfterValidator > ( schema, type_, config, build_context) ?
399
+ }
400
+ "function-wrap" => {
401
+ build_specific_validator :: < function:: FunctionWrapValidator > ( schema, type_, config, build_context) ?
389
402
}
390
- "function-wrap" => build_specific_validator :: < function:: FunctionBuilder > ( schema, type_, config, build_context) ?,
391
403
"default" => {
392
404
build_specific_validator :: < with_default:: WithDefaultValidator > ( schema, type_, config, build_context) ?
393
405
}
0 commit comments