Skip to content

Commit

Permalink
Add new validation methods
Browse files Browse the repository at this point in the history
Signed-off-by: Volkan Özçelik <[email protected]>
  • Loading branch information
v0lkan committed Dec 23, 2024
1 parent b813778 commit 72410e9
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions validation/validation.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package validation

import (
"github.com/google/uuid"
"regexp"

"github.com/spiffe/spike-sdk-go/api/errors"
Expand Down Expand Up @@ -67,3 +68,13 @@ func ValidatePathPattern(pathPattern string) error {

return nil
}

// ValidatePolicyId verifies if the given policyId is a valid UUID format.
// Returns errors.ErrInvalidInput if the validation fails.
func ValidatePolicyId(policyId string) error {
err := uuid.Validate(policyId)
if err != nil {
return errors.ErrInvalidInput
}
return nil
}

0 comments on commit 72410e9

Please sign in to comment.