paramo, params, and paramso should not filter out empty params #482

Closed
caiiiycuk opened this Issue Dec 11, 2014 · 6 comments

Projects

None yet

2 participants

@caiiiycuk
Contributor

Recently in old xitrum we use this template:

if (paramo("something").isEmpty) {
//   ...

With this we check only if parameter is passed to controller, like this http://my/controller?something=&.... After updating to latest xitrum this behaviour does not work.

As work around we use:

def isParamSet(name: String) =
  textParams.get(name).isDefined

May be this method should be added to default xitrum.Action, may be with different name. This method should only check is parameter passed to controller.

@ngocdaothanh ngocdaothanh changed the title from FeatureRequest isParamSet to Feature request: isParamSet Dec 11, 2014
@ngocdaothanh
Member

The problem is from #443.

Instead of adding isParamSet, I think I should fix paramo, params, and paramso to not filter out empty params.

Do you have further suggestion?

@caiiiycuk
Contributor

Yeahh i think that paramo should not filter empty string

@caiiiycuk caiiiycuk closed this Dec 11, 2014
@ngocdaothanh ngocdaothanh changed the title from Feature request: isParamSet to paramo, params, and paramso should not filter out empty params Dec 11, 2014
@caiiiycuk caiiiycuk reopened this Dec 11, 2014
@ngocdaothanh
Member

What do you think about how paramo[Int]("age") should behave when the param is an empty String? Throw exception? Return None?

@ngocdaothanh ngocdaothanh added this to the Xitrum 3.20 milestone Dec 11, 2014
@caiiiycuk
Contributor

I think that exception should thrown in this case.

@ngocdaothanh
Member

Thanks for the suggestion.
I'll release Xitrum 3.20 in a few hours.

@ngocdaothanh
Member

@georgeOsdDev

From Xitrum 3.20, instead of:

paramo[Int]("age")

Please write:

paramo("age").filter(_.nonEmpty).map(_.toInt)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment