Mark
Mark

Reputation: 69990

Play Framework custom validation errors with multiple String parameters

I'm trying to set a custom validation error with multiple params in Play!, but it seems like my validation parameters are not rendered correctly.

I have defined in messages:

validation.customerror=This is first param "%s", and this is the second "%s"

The in my code I execute:

validation.addError("","validation.customerror", "FIRST", "SECOND");

And I get:

This is first param "", and this is the second "FIRST"

instead of

This is first param "FIRST", and this is the second "SECOND"

Thoughts?

Upvotes: 1

Views: 1102

Answers (1)

Tommi
Tommi

Reputation: 8608

Define your validation message with index numbers like this:

validation.customerror=This is first param "%1$s", and this is the second "%2$s"

Take a look at Play Framework documentation for more information.

Upvotes: 1

Related Questions