From 25be867650de60ff13d4daa59e5bbac98ed07fa5 Mon Sep 17 00:00:00 2001 From: Kevin Pease Date: Fri, 24 May 2024 13:13:18 +0200 Subject: [PATCH] Add cursor value check --- stellar_rust_sdk_derive/src/lib.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/stellar_rust_sdk_derive/src/lib.rs b/stellar_rust_sdk_derive/src/lib.rs index 6e8c1df..e831474 100644 --- a/stellar_rust_sdk_derive/src/lib.rs +++ b/stellar_rust_sdk_derive/src/lib.rs @@ -12,6 +12,10 @@ pub fn pagination_macro(input: TokenStream) -> TokenStream { impl Paginatable for #struct_name { fn set_cursor(self, cursor: u32) -> Result { // Always accept the cursor since it's non-optional in the setter + if cursor < 1 { + return Err("Cursor must be greater than or equal to 1.".to_string()); + } + Ok(Self { cursor: Some(cursor), ..self }) }