mirror of
https://github.com/retailcrm/mg-transport-core.git
synced 2024-11-22 05:06:04 +03:00
Neur0toxine
d15ed7ffec
* lint stage for a workflow * golangci-lint config * lint only new code or last commit * run lint only for pull requests
21 lines
564 B
Go
21 lines
564 B
Go
package core
|
|
|
|
import (
|
|
"github.com/gin-gonic/gin/binding"
|
|
"github.com/go-playground/validator/v10"
|
|
)
|
|
|
|
// init here will register `validatecrmurl` function for gin validator.
|
|
func init() {
|
|
if v, ok := binding.Validator.Engine().(*validator.Validate); ok {
|
|
if err := v.RegisterValidation("validatecrmurl", validateCrmURL); err != nil {
|
|
panic("cannot register crm url validator: " + err.Error())
|
|
}
|
|
}
|
|
}
|
|
|
|
// validateCrmURL will validate CRM URL.
|
|
func validateCrmURL(fl validator.FieldLevel) bool {
|
|
return regCommandName.Match([]byte(fl.Field().String()))
|
|
}
|