Custom error-message for string validation?

YANG allows an int data type to have a range validator with a custom error-message.

Is there a similar way to have a custom error-message for pattern or length validation in a string data type? For example, something like:

type string {
pattern “[a-z]+” {
error-message “Value must be comprised of lowercase characters.”;
}
length “1…4” {
error-message “Length must be 1-4 characters.”;
}
}

Both of the above YANG statements + error-message substatements will work.
See the YANG RFCs pattern substatements and length substatements description.