-
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf: ⚡ share a validator instance across packages
- Loading branch information
Showing
8 changed files
with
31 additions
and
116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
8 changes: 4 additions & 4 deletions
8
internal/hass/event/validation.go → internal/validation/validation.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,23 @@ | ||
// Copyright 2024 Joshua Rich <[email protected]>. | ||
// SPDX-License-Identifier: MIT | ||
|
||
package event | ||
package validation | ||
|
||
import ( | ||
"strings" | ||
|
||
"github.com/go-playground/validator/v10" | ||
) | ||
|
||
var validate *validator.Validate | ||
var Validate *validator.Validate | ||
|
||
func init() { | ||
validate = validator.New(validator.WithRequiredStructEnabled()) | ||
Validate = validator.New(validator.WithRequiredStructEnabled()) | ||
} | ||
|
||
//nolint:errorlint | ||
//revive:disable:unhandled-error | ||
func parseValidationErrors(validation error) string { | ||
func ParseValidationErrors(validation error) string { | ||
validationErrs, ok := validation.(validator.ValidationErrors) | ||
if !ok { | ||
return "internal validation error" | ||
|