Initial cloud-services repo - gateway service + pkg modules

This commit is contained in:
Chris Rai
2026-01-30 23:14:52 -05:00
commit fbb820d7b3
1037 changed files with 171318 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
package validator
import (
"regexp"
"fiskerinc.com/modules/logger"
"github.com/go-playground/validator/v10"
"github.com/pkg/errors"
)
func validateCertSerial(fl validator.FieldLevel) bool {
ok, err := ValidateCertSerialSimple(fl.Field().String())
if err != nil {
logger.Err(err).Msg("Unable to validate certificate serial number")
}
return ok
}
func ValidateCertSerialSimple(serial string) (bool, error) {
matched, err := regexp.Match(`^([a-zA-Z0-9]{2}[:-]{1}){18,19}[a-zA-Z0-9]{2}$`, []byte(serial))
if err != nil {
return matched, errors.WithStack(err)
}
return matched, nil
}