File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 7878 /// Output type (must be JSON-serializable)
7979 type Output : Serialize + DeserializeOwned + Send ;
8080
81+ /// Validate the parameters for this task.
82+ /// This is called before spawning the task, to allow us to catch errors early.
83+ /// By default, this just tries to deserialize the parameters into the `Self::Params` type.
84+ fn validate_params ( & self , params : JsonValue ) -> Result < ( ) , TaskError > {
85+ let _typed_params: Self :: Params = serde_json:: from_value ( params) ?;
86+ Ok ( ( ) )
87+ }
88+
8189 /// Execute the task logic.
8290 ///
8391 /// Return `Ok(output)` on success, or `Err(TaskError)` on failure.
@@ -144,9 +152,7 @@ where
144152 }
145153
146154 fn validate_params ( & self , params : JsonValue ) -> Result < ( ) , TaskError > {
147- // For now, just deserialize
148- let _typed_params: T :: Params = serde_json:: from_value ( params) ?;
149- Ok ( ( ) )
155+ self . 0 . validate_params ( params)
150156 }
151157
152158 async fn execute (
You can’t perform that action at this time.
0 commit comments