mirror of
https://github.com/NginxProxyManager/nginx-proxy-manager.git
synced 2025-08-28 19:40:28 +00:00
Version 3 starter
This commit is contained in:
23
backend/internal/validator/hosts.go
Normal file
23
backend/internal/validator/hosts.go
Normal file
@@ -0,0 +1,23 @@
|
||||
package validator
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"npm/internal/entity/certificate"
|
||||
"npm/internal/entity/host"
|
||||
)
|
||||
|
||||
// ValidateHost will check if associated objects exist and other checks
|
||||
// will return a nil error if things are OK
|
||||
func ValidateHost(h host.Model) error {
|
||||
if h.CertificateID > 0 {
|
||||
// Check certificate exists and is valid
|
||||
// This will not determine if the certificate is Ready to use,
|
||||
// as this validation only cares that the row exists.
|
||||
if _, cErr := certificate.GetByID(h.CertificateID); cErr != nil {
|
||||
return fmt.Errorf("Certificate #%d does not exist", h.CertificateID)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
Reference in New Issue
Block a user