Skip to content

Commit

Permalink
1
Browse files Browse the repository at this point in the history
  • Loading branch information
Goalina committed Nov 12, 2024
1 parent d014bf0 commit 9414409
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions server/validate.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package server

import (
"fmt"
"github.com/metalogical/BigFiles/config"
"regexp"
)

type validateConfig struct {
ownerRegexp *regexp.Regexp
reponameRegexp *regexp.Regexp
usernameRegexp *regexp.Regexp
passwordRegexp *regexp.Regexp
}

var validatecfg validateConfig

func Init(cfg config.ValidateConfig) error {
var err error
validatecfg.ownerRegexp, err = regexp.Compile(cfg.OwnerRegexp)
if err != nil {
return fmt.Errorf("failed to compile owner regexp: %v", err)
}

validatecfg.reponameRegexp, err = regexp.Compile(cfg.RepoNameRegexp)
if err != nil {
return fmt.Errorf("failed to compile repo name regexp: %v", err)
}

validatecfg.usernameRegexp, err = regexp.Compile(cfg.UsernameRegexp)
if err != nil {
return fmt.Errorf("failed to compile username regexp: %v", err)
}

validatecfg.passwordRegexp, err = regexp.Compile(cfg.PasswordRegexp)
if err != nil {
return fmt.Errorf("failed to compile password regexp: %v", err)
}

return nil
}

0 comments on commit 9414409

Please sign in to comment.