Skip to content

Custom Databinder and i18N always load default value #7756

@Flo354

Description

@Flo354

Play Version (2.5.x / etc)

2.6.3

API (Scala / Java / Neither / Both)

Java

Operating System (Ubuntu 15.10 / MacOS 10.10 / Windows 10)

Linux Ubuntu 4.10.0-32-generic #36-Ubuntu SMP Tue Aug 8 12:10:06 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

JDK (Oracle 1.8.0_72, OpenJDK 1.8.x, Azul Zing)

java version "1.8.0_144"
Java(TM) SE Runtime Environment (build 1.8.0_144-b01)
Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode)

Expected Behavior

According to the custom databinder documentation

When the binding fails an array of errors keys is created, the first one defined in the messages file will be used. This array will generally contain:
["error.invalid.< fieldName >", "error.invalid.< type >", "error.invalid"]

I have a form like that

public class CreateOrganizationForm {

    @Constraints.Required
    private Phonenumber.PhoneNumber phone;

    public Phonenumber.PhoneNumber getPhone() {
        return phone;
    }

    public void setPhone(Phonenumber.PhoneNumber phone) {
        this.phone = phone;
    }
}

and my messages file contains:
error.invalid.phone=A valid phone number is required

When an invalid phone number is sent, i expect to receive the message:

A valid phone number is required

Actual Behavior

I receive the message:

Invalid value

which is the default value...

Linked pull request

Please note that I can not test the key error.invalid.< type > since it is a nested class and I can't use $ symbols in messages files.
#7755

Linked discussion

https://groups.google.com/forum/#!topic/play-framework/5XVJ0U52MFg

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions