File tree 1 file changed +9
-1
lines changed
model/src/main/kotlin/io/spine/validation
1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -49,7 +49,15 @@ import io.spine.validation.protodata.getDescriptor
49
49
*/
50
50
internal inline fun <reified T : Message > resolveErrorMessage (field : Field ): String {
51
51
val descriptor = T ::class .getDescriptor()
52
- val errorMessageField = descriptor.field(" error_msg " )
52
+ val errorMessageField = descriptor.field(CUSTOM_MESSAGE_FIELD )
53
53
val customMessage = field.findOption<T >()?.getField(errorMessageField) as String?
54
54
return customMessage ? : descriptor.defaultMessage
55
55
}
56
+
57
+ /* *
58
+ * The name of the field that contains a custom error message.
59
+ *
60
+ * This field name is a convention, which all companion error message options
61
+ * are expected to follow.
62
+ */
63
+ private const val CUSTOM_MESSAGE_FIELD = " error_msg"
You can’t perform that action at this time.
0 commit comments