-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PC-10133: Move api models to separate package (#143)
* add validation poc * further refine the validation example * current progress * simplify rule logic * remove v1alpha aliases * add errors tests * add rules tests * add strings tests * make sure labels testing is deterministic * invert dependency between project and v1alpha * facilitate recent suggestions and feedback * rename object validation to struct * fix error handling * change labels validation rule name * let compiler infer the type * declare the function once * move service to separate pkg * extract common validation * use common validators * revert changes * move replya away * come up with extended API for validaiton * remove unneccessary level * refactor naming to match fluent * move replay * extend tests coverage * move sli analysis away for time being * fix replya status through redefinition * fix prepending name solution
- Loading branch information
1 parent
3d2594b
commit f6ac5c9
Showing
32 changed files
with
969 additions
and
483 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -66,7 +66,6 @@ linters: | |
- exportloopref | ||
- gochecknoinits | ||
- gocognit | ||
- goconst | ||
- gocritic | ||
- gocyclo | ||
- gofmt | ||
|
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 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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// Package models defines sdk.Client API request and response models. | ||
package models |
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package models | ||
|
||
import ( | ||
"fmt" | ||
"reflect" | ||
"strings" | ||
|
||
"github.com/nobl9/nobl9-go/validation" | ||
) | ||
|
||
func newValidationError(model interface{}, errs []error) error { | ||
return ValidationError{ | ||
ModelName: reflect.TypeOf(model).Name(), | ||
Errors: errs, | ||
} | ||
} | ||
|
||
type ValidationError struct { | ||
ModelName string | ||
Errors []error | ||
} | ||
|
||
func (v ValidationError) Error() string { | ||
b := new(strings.Builder) | ||
b.WriteString(fmt.Sprintf("Validation for %s has failed for the following properties:\n", v.ModelName)) | ||
validation.JoinErrors(b, v.Errors, strings.Repeat(" ", 2)) | ||
return b.String() | ||
} |
Oops, something went wrong.