-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
103 additions
and
69 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 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,45 @@ | ||
package provider | ||
|
||
import "fmt" | ||
|
||
type listNotEmpty struct{} | ||
|
||
func (listNotEmpty) CheckValue(v any) error { | ||
val, ok := v.([]any) | ||
|
||
if !ok { | ||
return fmt.Errorf("expected []any value for ListNotEmpty check, got: %T", v) | ||
} | ||
|
||
if len(val) == 0 { | ||
return fmt.Errorf("expected non-empty list for ListNotEmpty check, but list was empty") | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func (listNotEmpty) String() string { | ||
return "non-empty list" | ||
} | ||
|
||
type listOfNonNulls struct{} | ||
|
||
func (listOfNonNulls) CheckValue(v any) error { | ||
val, ok := v.([]any) | ||
|
||
if !ok { | ||
return fmt.Errorf("expected []any value for ListOfNonNulls check, got: %T", v) | ||
} | ||
|
||
for i, item := range val { | ||
if item == nil { | ||
return fmt.Errorf("expected non-nil value at index %d for ListOfNonNulls check, but value was nil", i) | ||
} | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func (listOfNonNulls) String() string { | ||
return "list of non-nil values" | ||
} |