Spaces:
Configuration error
Configuration error
Download space/pkg/validation/validation.go from lifedebugger/api-qobiltu-dev: direct link, hf CLI and curl.
- Browser
- Download file 647 Bytes
-
https://huggingface.co/spaces/lifedebugger/api-qobiltu-dev/resolve/main/space/pkg/validation/validation.go
- Command line
-
hf download hf://spaces/lifedebugger/api-qobiltu-dev/space/pkg/validation/validation.go
-
curl -L -o validation.go https://huggingface.co/spaces/lifedebugger/api-qobiltu-dev/resolve/main/space/pkg/validation/validation.go
647 Bytes
| package validation | |
| import ( | |
| "context" | |
| "time" | |
| "gorm.io/gorm" | |
| ) | |
| type ErrorMessage struct { | |
| Field string `json:"field"` | |
| Message string `json:"-"` | |
| } | |
| func New(db *gorm.DB) (*Validator, error) { | |
| // Create source with 5 minute cache expiry | |
| expiry := 5 * time.Minute | |
| dbSource, err := NewDBOptionSource(db, expiry) | |
| if err != nil { | |
| return nil, err | |
| } | |
| // Start background refresh every 5 minutes | |
| ctx := context.Background() | |
| dbSource.StartAutoRefresh(ctx, 5*time.Minute) | |
| // create validator | |
| validator := NewValidator(dbSource) | |
| if err := validator.RegisterAllCustomRules(); err != nil { | |
| return nil, err | |
| } | |
| return validator, nil | |
| } | |