Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upgraded govalidator and added ULID validation rule #171

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -666,6 +666,7 @@ Below is the whole list of the rules provided by the `is` package:
* `UUIDv4`: validates if a string is a valid version 4 UUID
* `UUIDv5`: validates if a string is a valid version 5 UUID
* `UUID`: validates if a string is a valid UUID
* `ULID`: validates if a string is a valid ULID
* `CreditCard`: validates if a string is a valid credit card number
* `ISBN10`: validates if a string is an ISBN version 10
* `ISBN13`: validates if a string is an ISBN version 13
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ module github.com/go-ozzo/ozzo-validation/v4
go 1.13

require (
github.com/asaskevich/govalidator v0.0.0-20200108200545-475eaeb16496
github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d
github.com/stretchr/testify v1.4.0
)
5 changes: 2 additions & 3 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
github.com/asaskevich/govalidator v0.0.0-20200108200545-475eaeb16496 h1:zV3ejI06GQ59hwDQAvmK1qxOQGB3WuVTRoY0okPTAv0=
github.com/asaskevich/govalidator v0.0.0-20200108200545-475eaeb16496/go.mod h1:oGkLhpf+kjZl6xBf758TQhh5XrAeiJv/7FRz/2spLIg=
github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d h1:Byv0BzEl3/e6D5CLfI0j/7hiIEtvGVFPCZ7Ei2oq8iQ=
github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw=
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0 h1:4G4v2dO3VZwixGIRoQ5Lfboy6nUhCyYzaqnIAPPhYs4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
Expand Down
4 changes: 4 additions & 0 deletions is/rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ var (
ErrUUIDv5 = validation.NewError("validation_is_uuid_v5", "must be a valid UUID v5")
// ErrUUID is the error that returns in case of an invalid UUID value.
ErrUUID = validation.NewError("validation_is_uuid", "must be a valid UUID")
// ErrULID is the error that returns in case of an invalid ULID value.
ErrULID = validation.NewError("validation_is_ulid", "must be a valid ULID")
// ErrCreditCard is the error that returns in case of an invalid credit card number.
ErrCreditCard = validation.NewError("validation_is_credit_card", "must be a valid credit card number")
// ErrISBN10 is the error that returns in case of an invalid ISBN-10 value.
Expand Down Expand Up @@ -171,6 +173,8 @@ var (
UUIDv5 = validation.NewStringRuleWithError(govalidator.IsUUIDv5, ErrUUIDv5)
// UUID validates if a string is a valid UUID
UUID = validation.NewStringRuleWithError(govalidator.IsUUID, ErrUUID)
// ULID validates if a string is a valid ULID
ULID = validation.NewStringRuleWithError(govalidator.IsULID, ErrULID)
// CreditCard validates if a string is a valid credit card number
CreditCard = validation.NewStringRuleWithError(govalidator.IsCreditCard, ErrCreditCard)
// ISBN10 validates if a string is an ISBN version 10
Expand Down