@@ -114,6 +114,30 @@ pub struct SessionConfig {
114114
115115 /// The schedule configuration for the session
116116 pub schedule : Option < ScheduleConfig > ,
117+
118+ /// The validation configuration for the session
119+ #[ serde( default ) ]
120+ pub verification : VerificationConfig ,
121+ }
122+
123+ #[ derive( Clone , Debug , Deserialize ) ]
124+ /// The configuration of validation rules.
125+ pub struct VerificationConfig {
126+ /// Specifies whether we should check the original sending time for admin messages.
127+ #[ serde( default = "default_true" ) ]
128+ pub check_orig_sending_time_for_admin : bool ,
129+ }
130+
131+ impl Default for VerificationConfig {
132+ fn default ( ) -> Self {
133+ Self {
134+ check_orig_sending_time_for_admin : true ,
135+ }
136+ }
137+ }
138+
139+ fn default_true ( ) -> bool {
140+ true
117141}
118142
119143/// Errors that may occur when loading configuration.
@@ -170,6 +194,11 @@ reset_on_logon = false
170194 assert_eq ! ( session_config. tls_config, Some ( expected_tls_config) ) ;
171195 assert_eq ! ( session_config. reconnect_interval, 30 ) ;
172196 assert_eq ! ( session_config. logon_timeout, 10 ) ;
197+ assert ! (
198+ session_config
199+ . verification
200+ . check_orig_sending_time_for_admin
201+ ) ;
173202 }
174203
175204 #[ test]
@@ -439,6 +468,53 @@ end_day = "Friday"
439468 assert_eq ! ( session_config. reconnect_interval, 15 ) ;
440469 }
441470
471+ #[ test]
472+ fn test_verification_config_defaults_when_omitted ( ) {
473+ let config_contents = r#"
474+ [[sessions]]
475+ begin_string = "FIX.4.4"
476+ sender_comp_id = "send-comp-id"
477+ target_comp_id = "target-comp-id"
478+ connection_port = 443
479+ connection_host = "127.0.0.1"
480+ heartbeat_interval = 30
481+ "# ;
482+
483+ let config: Config = toml:: from_str ( config_contents) . unwrap ( ) ;
484+ let session_config = config. sessions . first ( ) . unwrap ( ) ;
485+
486+ assert ! (
487+ session_config
488+ . verification
489+ . check_orig_sending_time_for_admin
490+ ) ;
491+ }
492+
493+ #[ test]
494+ fn test_verification_config_can_disable_admin_orig_sending_time_check ( ) {
495+ let config_contents = r#"
496+ [[sessions]]
497+ begin_string = "FIX.4.4"
498+ sender_comp_id = "send-comp-id"
499+ target_comp_id = "target-comp-id"
500+ connection_port = 443
501+ connection_host = "127.0.0.1"
502+ heartbeat_interval = 30
503+
504+ [sessions.verification]
505+ check_orig_sending_time_for_admin = false
506+ "# ;
507+
508+ let config: Config = toml:: from_str ( config_contents) . unwrap ( ) ;
509+ let session_config = config. sessions . first ( ) . unwrap ( ) ;
510+
511+ assert ! (
512+ !session_config
513+ . verification
514+ . check_orig_sending_time_for_admin
515+ ) ;
516+ }
517+
442518 #[ test]
443519 fn test_load_from_path_success ( ) {
444520 let config_contents = r#"
0 commit comments