Validate tags with regex

This commit is contained in:
Hubert Van De Walle 2020-08-17 17:15:14 +02:00
parent 5295e32d86
commit 25e29afcbb

View File

@ -22,6 +22,9 @@ internal object NoteValidations {
NoteMetadata::tags onEach { NoteMetadata::tags onEach {
maxLength(15) maxLength(15)
addConstraint("must not be blank") { it.isNotBlank() } addConstraint("must not be blank") { it.isNotBlank() }
addConstraint("must only contain alphanumeric characters, `-` and `_`") {
it.matches("^[a-zA-Z0-9-_]+\$".toRegex())
}
} }
} }