poteto / ember-changeset-validations

Validations for ember-changeset
http://bit.ly/ember-changeset-demo
Other
220 stars 98 forks source link

Provided description for validation not passed in rawOutput for buildMessage #354

Open freyjameetsmel opened 4 months ago

freyjameetsmel commented 4 months ago

Hey there, 👋

I'm currently working on internationalizing our application. This also includes all our validation messages. To get this to work properly for the default messages

This works as expected, except for the provided descriptions.

Example

Validation when creating the changeset

lastname: [
  validatePresence({ presence: true, description: 'Nachname' }),
],

RawOutput

{
    "value": "",
    "type": "present",
    "message": "validation.defaultMessages.present", // path for tranlation for ember-intl
    "context": {
        "presence": true,
        "description": "Lastname" // expected to be "Nachname"
    }
}

The rendered description in the rawOutput is basically the key, but should be the description provided by the validation, if present. 🤔

I hope I did not overlook something that could result in the correct behaviour for our application. I could also try to provide a PR for this issue.

Thanks ✨ Mel


Version used

"ember-changeset-validations": "4.1.1",