Hey Karsten, 

I had a similar doubt and following Daniel's recommendation I went with the same route you did (using {s.int} to convert to integer).

Quote from another thread: "you can also convert the header value to integer using the transformation {s.int}, that's safer if you need to do other types of comparison such as > or <, because comparing string values might give the result you don't expect"

Hope this helps!

Joel.

On Fri, Oct 18, 2019 at 10:58 AM Karsten Horsmann <khorsmann@gmail.com> wrote:
Hi List,

I use Kamailio 5.2.x and I want to fetch an value from an X Header and do some checks like "is not empty" and "should be an integer". 

AFAIK per default all values are strings with the hdr function. 

What are the best way for some validations within Kamailio script language? 
 

if(is_present_hf("X-someheader")) {
                        $avp(routing_target) = $(hdr(X-someheader){s.int});
                                                                     if(!ds_list_exists("$avp(routing_target)")) 
Cheers 
Karsten Horsmann 
_______________________________________________
Kamailio (SER) - Users Mailing List
sr-users@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users