mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-10-29 09:32:24 -05:00
start working on struct validation for gtsmodel
This commit is contained in:
parent
7d193de25f
commit
d2276fc553
10 changed files with 407 additions and 125 deletions
|
|
@ -90,6 +90,7 @@ var (
|
|||
followPathRegex = regexp.MustCompile(followPathRegexString)
|
||||
|
||||
ulidRegexString = `[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{26}`
|
||||
ulidRegex = regexp.MustCompile(fmt.Sprintf(`^%s$`, ulidRegexString))
|
||||
|
||||
likedPathRegexString = fmt.Sprintf(`^/?%s/(%s)/%s$`, UsersPath, usernameRegexString, LikedPath)
|
||||
// likedPathRegex parses a path that validates and captures the username part from eg /users/example_username/liked
|
||||
|
|
|
|||
|
|
@ -171,3 +171,8 @@ func ValidateSiteTerms(t string) error {
|
|||
|
||||
return nil
|
||||
}
|
||||
|
||||
// ValidateULID returns true if the passed string is a valid ULID.
|
||||
func ValidateULID(i string) bool {
|
||||
return ulidRegex.MatchString(i)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue