@@ -27,7 +27,8 @@ pub fn validate_create_identity(
27
27
} else {
28
28
return Err ( ValidationError :: FieldEmpty ( Field :: Email ) ) ;
29
29
}
30
- postal_address. validate ( ) ?;
30
+ // For Ident, the postal address needs to be fully set
31
+ postal_address. validate_to_be_non_optional ( ) ?;
31
32
util:: validate_file_upload_id ( profile_picture_file_upload_id. as_deref ( ) ) ?;
32
33
util:: validate_file_upload_id ( identity_document_file_upload_id. as_deref ( ) ) ?;
33
34
}
@@ -70,7 +71,10 @@ pub fn validate_update_identity(
70
71
#[ cfg( test) ]
71
72
mod tests {
72
73
use super :: * ;
73
- use crate :: { OptionalPostalAddress , ValidationError , identity:: IdentityType } ;
74
+ use crate :: {
75
+ OptionalPostalAddress , ValidationError , identity:: IdentityType ,
76
+ tests:: tests:: valid_optional_address,
77
+ } ;
74
78
use rstest:: rstest;
75
79
76
80
#[ test]
@@ -87,15 +91,18 @@ mod tests {
87
91
}
88
92
89
93
#[ rstest]
90
- #[ case:: invalid_name( IdentityType :: Anon , "" , & None , & OptionalPostalAddress :: empty( ) , & None , & None , ValidationError :: FieldEmpty ( Field :: Name ) ) ]
91
- #[ case:: ident_no_email( IdentityType :: Ident , "some name" , & None , & OptionalPostalAddress :: empty( ) , & None , & None , ValidationError :: FieldEmpty ( Field :: Email ) ) ]
92
- #[ case:: ident_blank_email( IdentityType :: Ident , "some name" , & Some ( "" . into( ) ) , & OptionalPostalAddress :: empty( ) , & None , & None , ValidationError :: FieldEmpty ( Field :: Email ) ) ]
93
- #[ case:: ident_blank_address( IdentityType :: Ident , "some name" , & Some ( "[email protected] " . into( ) ) , & OptionalPostalAddress { country: None , city: None , zip: None , address: Some ( "" . into( ) ) } , & None , & None , ValidationError :: FieldEmpty ( Field :: Address ) ) ]
94
- #[ case:: ident_blank_city( IdentityType :: Ident , "some name" , & Some ( "[email protected] " . into( ) ) , & OptionalPostalAddress { country: None , address: None , zip: None , city: Some ( "" . into( ) ) } , & None , & None , ValidationError :: FieldEmpty ( Field :: City ) ) ]
95
- #[ case:: ident_blank_country( IdentityType :: Ident , "some name" , & Some ( "[email protected] " . into( ) ) , & OptionalPostalAddress { address: None , city: None , zip: None , country: Some ( "" . into( ) ) } , & None , & None , ValidationError :: FieldEmpty ( Field :: Country ) ) ]
96
- #[ case:: ident_blank_zip( IdentityType :: Ident , "some name" , & Some ( "[email protected] " . into( ) ) , & OptionalPostalAddress { country: None , city: None , address: None , zip: Some ( "" . into( ) ) } , & None , & None , ValidationError :: FieldEmpty ( Field :: Zip ) ) ]
97
- #[ case:: ident_blank_profile_pic( IdentityType :: Ident , "some name" , & Some ( "[email protected] " . into( ) ) , & OptionalPostalAddress :: empty( ) , & Some ( "" . into( ) ) , & None , ValidationError :: InvalidFileUploadId ) ]
98
- #[ case:: ident_blank_identity_doc( IdentityType :: Ident , "some name" , & Some ( "[email protected] " . into( ) ) , & OptionalPostalAddress :: empty( ) , & None , & Some ( "" . into( ) ) , ValidationError :: InvalidFileUploadId ) ]
94
+ #[ case:: invalid_name( IdentityType :: Anon , "" , & None , & valid_optional_address( ) , & None , & None , ValidationError :: FieldEmpty ( Field :: Name ) ) ]
95
+ #[ case:: ident_no_email( IdentityType :: Ident , "some name" , & None , & valid_optional_address( ) , & None , & None , ValidationError :: FieldEmpty ( Field :: Email ) ) ]
96
+ #[ case:: ident_blank_email( IdentityType :: Ident , "some name" , & Some ( "" . into( ) ) , & valid_optional_address( ) , & None , & None , ValidationError :: FieldEmpty ( Field :: Email ) ) ]
97
+ #[ case:: ident_blank_address( IdentityType :: Ident , "some name" , & Some ( "[email protected] " . into( ) ) , & OptionalPostalAddress { country: Some ( "AT" . to_string( ) ) , city: Some ( "Vienna" . to_string( ) ) , zip: None , address: Some ( "" . into( ) ) } , & None , & None , ValidationError :: FieldEmpty ( Field :: Address ) ) ]
98
+ #[ case:: ident_empty_address( IdentityType :: Ident , "some name" , & Some ( "[email protected] " . into( ) ) , & OptionalPostalAddress { country: Some ( "AT" . to_string( ) ) , city: Some ( "Vienna" . to_string( ) ) , zip: None , address: None } , & None , & None , ValidationError :: FieldEmpty ( Field :: Address ) ) ]
99
+ #[ case:: ident_blank_city( IdentityType :: Ident , "some name" , & Some ( "[email protected] " . into( ) ) , & OptionalPostalAddress { country: Some ( "AT" . to_string( ) ) , address: Some ( "addr 1" . to_string( ) ) , zip: None , city: Some ( "" . into( ) ) } , & None , & None , ValidationError :: FieldEmpty ( Field :: City ) ) ]
100
+ #[ case:: ident_empty_city( IdentityType :: Ident , "some name" , & Some ( "[email protected] " . into( ) ) , & OptionalPostalAddress { country: Some ( "AT" . to_string( ) ) , address: Some ( "addr 1" . to_string( ) ) , zip: None , city: Some ( "" . into( ) ) } , & None , & None , ValidationError :: FieldEmpty ( Field :: City ) ) ]
101
+ #[ case:: ident_blank_country( IdentityType :: Ident , "some name" , & Some ( "[email protected] " . into( ) ) , & OptionalPostalAddress { address: Some ( "addr 1" . to_string( ) ) , city: Some ( "Vienna" . to_string( ) ) , zip: None , country: Some ( "" . into( ) ) } , & None , & None , ValidationError :: FieldEmpty ( Field :: Country ) ) ]
102
+ #[ case:: ident_empty_country( IdentityType :: Ident , "some name" , & Some ( "[email protected] " . into( ) ) , & OptionalPostalAddress { address: Some ( "addr 1" . to_string( ) ) , city: Some ( "Vienna" . to_string( ) ) , zip: None , country: None } , & None , & None , ValidationError :: FieldEmpty ( Field :: Country ) ) ]
103
+ #[ case:: ident_blank_zip( IdentityType :: Ident , "some name" , & Some ( "[email protected] " . into( ) ) , & OptionalPostalAddress { country: Some ( "AT" . to_string( ) ) , city: Some ( "Vienna" . to_string( ) ) , address: Some ( "addr 1" . to_string( ) ) , zip: Some ( "" . into( ) ) } , & None , & None , ValidationError :: FieldEmpty ( Field :: Zip ) ) ]
104
+ #[ case:: ident_blank_profile_pic( IdentityType :: Ident , "some name" , & Some ( "[email protected] " . into( ) ) , & valid_optional_address( ) , & Some ( "" . into( ) ) , & None , ValidationError :: InvalidFileUploadId ) ]
105
+ #[ case:: ident_blank_identity_doc( IdentityType :: Ident , "some name" , & Some ( "[email protected] " . into( ) ) , & valid_optional_address( ) , & None , & Some ( "" . into( ) ) , ValidationError :: InvalidFileUploadId ) ]
99
106
fn test_validate_create_identity_errors (
100
107
#[ case] t : IdentityType ,
101
108
#[ case] name : & str ,
0 commit comments