Skip to content

Commit f2c31d7

Browse files
committed
address CR
1 parent 417f583 commit f2c31d7

File tree

1 file changed

+17
-16
lines changed

1 file changed

+17
-16
lines changed

sources/platform/actors/development/actor_definition/input_schema/custom_error_messages.md

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,13 @@ slug: /actors/development/actor-definition/input-schema/custom-error-messages
88

99
---
1010

11-
When an input fails validation against an Actor's input schema, the resulting errors are processed and displayed to the user. By default, these messages are generic and may not clearly convey the specific semantic meaning behind validation rules.
11+
When an input fails validation against an Actor's input schema, the resulting errors are processed and displayed to the user. By default, these messages are generic and may not clearly explain what the validation rule actually means.
1212

1313
Custom error messages allow Actor developers to define tailored feedback messages for input validation errors, making it easier for users to understand what is required and improving overall usability.
1414

1515
## The problem with generic error messages
1616

17-
Some validation rules defined by Actor developers carry specific semantic meaning that cannot be clearly conveyed by generic error messages.
18-
19-
For example, consider the following input field using the `pattern` validation keyword:
17+
Some validation rules have a specific purpose that generic error messages don't explain well. For example, consider the following input field using the `pattern` validation keyword:
2018

2119
```json
2220
{
@@ -28,7 +26,7 @@ For example, consider the following input field using the `pattern` validation k
2826
}
2927
```
3028

31-
Input that don't satisfy the pattern, will produce an error message like:
29+
Input that doesn't satisfy the pattern will produce an error message like:
3230

3331
```text
3432
Field "email" should match pattern "^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$".
@@ -40,9 +38,9 @@ However, a message such as the following would be much more understandable for t
4038
Field "email" must be a valid email address.
4139
```
4240

43-
## Using the `errorMessage` keyword
41+
## Custom error messages for input fields
4442

45-
Each property in the [input schema](./index.md) can include an `errorMessage` field that defines custom error messages to be displayed when validation of that field fails.
43+
Each property in the [input schema](./index.md) can include an `errorMessage` field that defines a custom error message to be displayed when validation of that field fails.
4644

4745
The `errorMessage` must be an object that maps *validation keywords* (e.g., `type`, `pattern`, `minLength`) to their respective custom messages.
4846

@@ -62,9 +60,11 @@ The `errorMessage` must be an object that maps *validation keywords* (e.g., `typ
6260

6361
If a validation error occurs for a keyword that is not listed in the `errorMessage` object, the system will fall back to the default error message.
6462

65-
::::note
66-
Custom error messages are especially useful for complex validation rules like regular expressions, where the default error message would show the entire pattern, which is not user-friendly. See [best practices](#best-practices) for more guidance.
67-
::::
63+
:::note User-Friendly Messages
64+
65+
Custom error messages are especially useful for complex validation rules like regular expressions, where the default error message would show the entire pattern, which is not user-friendly. Refer to the [best practices](#best-practices) for more guidance.
66+
67+
:::
6868

6969
### Supported validation keywords
7070

@@ -102,11 +102,12 @@ It's possible to define custom error messages in sub-properties as well. For obj
102102

103103
## Best practices
104104

105-
While custom error messages can improve the user experience by providing clearer guidance, it's generally better to rely on the default error messages unless there's a specific need for customization. Only use custom error messages when they significantly help users understand the requirements better than the default messages.
105+
Custom error messages can be useful in specific cases, but they aren't always necessary. In most situations, the default validation messages are clear enough and ensure consistency across the platform. Use custom messages only when they meaningfully improve clarity—for example, when the default message would expose an unreadable regular expression or fail to explain a non-obvious requirement.
106+
107+
If you choose to add custom messages, keep the following in mind:
106108

107-
If you do decide to use custom error messages, follow these best practices:
109+
1. Be specific – The message should clarify what went wrong.
110+
1. Be concise – Avoid long or overly detailed explanations.
111+
1. Be helpful – Focus on what the user needs to change.
112+
1. Be consistent – Align with the tone and style used elsewhere in your project.
108113

109-
1. **Be specific** - Clearly explain what is required or what went wrong
110-
2. **Be concise** - Keep messages short and to the point
111-
3. **Be helpful** - Provide guidance on how to fix the issue
112-
4. **Be consistent** - Use a similar tone and style across all messages

0 commit comments

Comments
 (0)