How to validate an attribute is defined in Gatling 2?

in 1.5.3 I could use isAttributeDefined(attributeKey: String) defined at here: https://github.com/excilys/gatling/wiki/Session#wiki-members

according to Gatling 2 wiki: https://github.com/excilys/gatling/wiki/Gatling-2#wiki-session, this API is not available any more. I basically want to use that in the doIf condition.

i tried

doIf(session => session(“parentCardId”).validate[String]) {
exec(

error message said:

type mismatch;
found : io.gatling.core.validation.Validation[String]
required: io.gatling.core.validation.Validation[Boolean]
16:44:35.309 [ERROR] i.g.a.ZincCompiler$ - .doIf(session => session(“userCardId”).validate[String]) {
16:44:35.309 [ERROR] i.g.a.ZincCompiler$ - ^

but if i replace String with Boolean, error said

value validate is not a member of String
16:32:24.886 [ERROR] i.g.a.ZincCompiler$ - doIf(session => session(“parentCardId”.validate[Boolean]))

Any ideas?

There was a typo in the second try but i fixed that still got this error:
17:09:24.760 [ERROR] i.g.c.action.If - Can’t cast value 60016 of type class java.lang.String into boolean

finally I use this one and it works:

doIf(session => session(“parentCardId”).validate[String].map(_ != null)) {
exec(

isnt it using null a bad idea in scala? any other simple way of doing this?

在 2014年1月21日星期二UTC-8下午4时46分43秒,Kan Wu写道:

If you just want to check that “parentCardId” exists in the session, why not just:
doIf(session => session.contains(“parentCardId”))

or shorter:
doIf(_.contains(“parentCardId”))

your way works perfect! thanks!

do you know any where we can find a full list of APIs that session or other objects?

在 2014年1月21日星期二UTC-8下午5时31分36秒,Stéphane Landelle写道:

For now, you’ll have to browse the code: https://github.com/excilys/gatling/blob/master/gatling-core/src/main/scala/io/gatling/core/session/Session.scala#L71-L76
We’ll document the whole thing in the next weeks.