Skip to content

Commit

Permalink
feat: Reduce the character restriction of the name field
Browse files Browse the repository at this point in the history
Add characters :;= to reduce the character restriction.
- In BACNet protocol, the user might combine object type and property as the resourceName, for example, analog_input_0:present-value
- In OPC_UA protocol, the user might use NodeId as the resourceName, for example, ns=10;s=Hello:World

Close #750

Signed-off-by: bruce <[email protected]>
  • Loading branch information
weichou1229 committed Sep 29, 2022
1 parent 1091de3 commit 49dcdfb
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions common/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const (
const (
// Per https://tools.ietf.org/html/rfc3986#section-2.3, unreserved characters= ALPHA / DIGIT / "-" / "." / "_" / "~"
// Also due to names used in topics for Redis Pub/Sub, "."are not allowed
rFC3986UnreservedCharsRegexString = "^[a-zA-Z0-9-_~]+$"
rFC3986UnreservedCharsRegexString = "^[a-zA-Z0-9-_~:;=]+$"
intervalDatetimeLayout = "20060102T150405"
name = "Name"
)
Expand Down Expand Up @@ -95,7 +95,7 @@ func getErrorMessage(e validator.FieldError) string {
case dtoNoneEmptyStringTag:
msg = fmt.Sprintf("%s field should not be empty string", fieldName)
case dtoRFC3986UnreservedCharTag:
msg = fmt.Sprintf("%s field only allows unreserved characters which are ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_~", fieldName)
msg = fmt.Sprintf("%s field only allows unreserved characters which are ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_~:;=", fieldName)
default:
msg = fmt.Sprintf("%s field validation failed on the %s tag", fieldName, tag)
}
Expand Down

0 comments on commit 49dcdfb

Please sign in to comment.