You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
12
12
13
13
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.
14
14
15
15
## The problem with generic error messages
16
16
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:
20
18
21
19
```json
22
20
{
@@ -28,7 +26,7 @@ For example, consider the following input field using the `pattern` validation k
28
26
}
29
27
```
30
28
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:
32
30
33
31
```text
34
32
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
40
38
Field "email" must be a valid email address.
41
39
```
42
40
43
-
## Using the `errorMessage` keyword
41
+
## Custom error messages for input fields
44
42
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.
46
44
47
45
The `errorMessage` must be an object that maps *validation keywords* (e.g., `type`, `pattern`, `minLength`) to their respective custom messages.
48
46
@@ -62,9 +60,11 @@ The `errorMessage` must be an object that maps *validation keywords* (e.g., `typ
62
60
63
61
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.
64
62
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
+
:::
68
68
69
69
### Supported validation keywords
70
70
@@ -102,11 +102,12 @@ It's possible to define custom error messages in sub-properties as well. For obj
102
102
103
103
## Best practices
104
104
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:
106
108
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.
108
113
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