24 lines
423 B
Go
24 lines
423 B
Go
|
|
package sites
|
||
|
|
|
||
|
|
import (
|
||
|
|
"emperror.dev/errors"
|
||
|
|
validation "github.com/go-ozzo/ozzo-validation/v4"
|
||
|
|
)
|
||
|
|
|
||
|
|
func stringEquals(str string) validation.RuleFunc {
|
||
|
|
return func(value interface{}) error {
|
||
|
|
s, _ := value.(string)
|
||
|
|
if s != str {
|
||
|
|
return errors.New("unexpected string")
|
||
|
|
}
|
||
|
|
return nil
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
func defaultIfEmpty(value string, defaultValue string) string {
|
||
|
|
if value == "" {
|
||
|
|
return defaultValue
|
||
|
|
}
|
||
|
|
return value
|
||
|
|
}
|