upb-uc4 / lagom-core

Repository for the micro service backend using lagom.
Apache License 2.0
6 stars 0 forks source link

User Validation #276

Closed bastihav closed 4 years ago

bastihav commented 4 years ago

Describe the bug User Validation does not report duplicate username until all parameters are valid.

To Reproduce

{
    "authUser": {
        "username": "admin",
        "password": "",
        "role": "Admin"
    },
    "admin": {
    "username": "admin",
    "role": "Admin",
    "address": {
        "street": "",
        "houseNumber": "",
        "zipCode": "",
        "city": "",
        "country": ""
    },
    "firstName": "",
    "lastName": "",
    "picture": "",
    "email": "",
    "birthDate": "",
    "phoneNumber": "",
    "latestImmatriculation": "",
    "matriculationId": ""
}
}

yields

{
    "type": "Validation",
    "title": "Your request parameters did not validate",
    "invalidParams": [
        {
            "name": "admin.address.street",
            "reason": "Street must only contain at letters and '-''."
        },
        {
            "name": "admin.address.houseNumber",
            "reason": "House number must not be empty."
        },
        {
            "name": "admin.address.zipCode",
            "reason": "Zipcode must consist of exactly five digits."
        },
        {
            "name": "admin.address.city",
            "reason": "City name contains illegal characters."
        },
        {
            "name": "admin.address.country",
            "reason": "Country must be one of Germany, United States, Italy, France, United Kingdom, Belgium, Netherlands, Spain, Austria, Switzerland, Poland."
        },
        {
            "name": "admin.email",
            "reason": "Email must be in email format example@xyz.com."
        },
        {
            "name": "admin.birthDate",
            "reason": "Birthdate must be of the following format \"yyyy-mm-dd\"."
        },
        {
            "name": "admin.phoneNumber",
            "reason": "Phone number must be of the following format \"+xxxxxxxxxxxx\"."
        },
        {
            "name": "admin.firstName",
            "reason": "First name must contain between 1 and 100 characters."
        },
        {
            "name": "admin.lastName",
            "reason": "Last name must contain between 1 and 100 characters."
        },
        {
            "name": "authUser.password",
            "reason": "Password must not be empty."
        }
    ]
}

Expected behavior Invalid params includes duplicate username error

Additional context Experimental cluster