diff --git a/node.js/cds-i18n.md b/node.js/cds-i18n.md index 2df1c38d1..6c32988ef 100644 --- a/node.js/cds-i18n.md +++ b/node.js/cds-i18n.md @@ -674,11 +674,11 @@ Ensure you correctly understand how the config option `cds.i18n.folders` work be These are the current i18n entries for [`cds.i18n.messages`](#messages) used by the CAP runtime, which you can provide own translations for in your app-specific `_i18n/messages_.properties` files: ```properties -MULTIPLE_ERRORS = Multiple errors occurred. Please see the details for more information. -ASSERT_FORMAT = Value "{0}" is not in specified format "{1}" -ASSERT_RANGE = Value {0} is not in specified range [{1}, {2}] -ASSERT_ENUM = Value {0} is invalid according to enum declaration {{1}} -ASSERT_NOT_NULL = Value is required +MULTIPLE_ERRORS = Multiple errors occurred, see details below. +ASSERT_FORMAT = Enter a value matching the pattern {1}. +ASSERT_RANGE = Enter a value between {1} and {2}. +ASSERT_ENUM = Enter one of the allowed values: {1}. +ASSERT_MANDATORY = Provide the missing value. ``` In addition the following HTTP status codes can be translated: diff --git a/node.js/events.md b/node.js/events.md index 120767105..8fdb54101 100644 --- a/node.js/events.md +++ b/node.js/events.md @@ -612,3 +612,21 @@ Content-Type: application/json > In production, error responses should never disclose internal information that could be exploited by attackers. To ensure that, all errors with a `5xx` status code are returned to the client with only the respective generic message (example: `500 Internal Server Error`). > > In very rare cases, you might want to return 5xx errors with a meaningful message to the client. This can be achieved with `err.$sanitize = false`. Use that option with care! + + +## Translations for Validation Errors + +For the following annotations/error codes, the runtime provides default translations: + +| Annotation | Error Code | +|-------------------------|---------------------------------| +| `@mandatory` | ASSERT_MANDATORY(1) | +| `@assert.range` | ASSERT_RANGE | +| `@assert.range` on enum | ASSERT_ENUM | +| `@assert.format` | ASSERT_FORMAT | +| `@assert.target` | ASSERT_TARGET | + +(1) Falls back to error code `ASSERT_NOT_NULL` if provided in custom translations. + +These can be overridden by the known technique of providing [custom i18n messages](cds-i18n#localized-messages). +