Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions node.js/cds-i18n.md
Original file line number Diff line number Diff line change
Expand Up @@ -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_<locale>.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:
Expand Down
18 changes: 18 additions & 0 deletions node.js/events.md
Original file line number Diff line number Diff line change
Expand Up @@ -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<sup>(1)</sup> |
| `@assert.range` | ASSERT_RANGE |
| `@assert.range` on enum | ASSERT_ENUM |
| `@assert.format` | ASSERT_FORMAT |
| `@assert.target` | ASSERT_TARGET |

<sup>(1)</sup> 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).