3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
[submodule "pkg/validator/data/disposable-email-domains"]
|
||||
path = pkg/validator/data/disposable-email-domains
|
||||
url = git@github.com:disposable-email-domains/disposable-email-domains.git
|
||||
@@ -31,6 +31,7 @@ import (
|
||||
"go.probo.inc/probo/pkg/gid"
|
||||
"go.probo.inc/probo/pkg/probo"
|
||||
"go.probo.inc/probo/pkg/statelesstoken"
|
||||
"go.probo.inc/probo/pkg/validator"
|
||||
)
|
||||
|
||||
type (
|
||||
@@ -54,6 +55,14 @@ const (
|
||||
TrustCenterAccessURLFormat = "https://%s/organizations/%s/trust-center/access"
|
||||
)
|
||||
|
||||
func (tcar *TrustCenterAccessRequest) Validate() error {
|
||||
v := validator.New()
|
||||
|
||||
v.Check(tcar.Email, "email", validator.NotOneOfSlice([]string{}))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s TrustCenterAccessService) ValidateToken(
|
||||
ctx context.Context,
|
||||
trustCenterID gid.GID,
|
||||
|
||||
1
pkg/validator/data/disposable-email-domains
Submodule
1
pkg/validator/data/disposable-email-domains
Submodule
Submodule pkg/validator/data/disposable-email-domains added at e38ace196d
1
pkg/validator/validator_email.go
Normal file
1
pkg/validator/validator_email.go
Normal file
@@ -0,0 +1 @@
|
||||
package validator
|
||||
@@ -225,6 +225,25 @@ func OneOfSlice[T any](allowed []T) ValidatorFunc {
|
||||
}
|
||||
}
|
||||
|
||||
// NotOneOfSlice validates that a value is not one of the values in the slice.
|
||||
// Accepts a slice of any type. Compares by value first, then by string representation.
|
||||
func NotOneOfSlice[T any](disallowed []T) ValidatorFunc {
|
||||
oneOfSlice := OneOfSlice(disallowed)
|
||||
|
||||
return func(value any) *ValidationError {
|
||||
err := oneOfSlice(disallowed)
|
||||
|
||||
if err == nil {
|
||||
return newValidationError(
|
||||
ErrorCodeInvalidEnum,
|
||||
"must not be one of the disallowed values",
|
||||
)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// OneOf validates that a value is one of the allowed values.
|
||||
// Accepts strings or types that implement fmt.Stringer as variadic arguments.
|
||||
func OneOf(allowed ...any) ValidatorFunc {
|
||||
|
||||
Reference in New Issue
Block a user