-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add struct util functions and default struct tags #331
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #331 +/- ##
==========================================
- Coverage 77.10% 76.89% -0.21%
==========================================
Files 52 52
Lines 3389 3406 +17
==========================================
+ Hits 2613 2619 +6
- Misses 568 578 +10
- Partials 208 209 +1 ☔ View full report in Codecov by Sentry. |
@@ -9,19 +9,15 @@ import ( | |||
|
|||
func TestCreateTool(t *testing.T) { | |||
// Arrange | |||
toolCreateInput := autopilot.Register[ol.ToolCreateInput]("tool_create_input", ol.NewExampleOf[ol.ToolCreateInput]()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OMG 🚀
utils.go
Outdated
var structValidator = validator.New(validator.WithRequiredStructEnabled()) | ||
|
||
// Validates resource's `validate:""` struct tags | ||
func IsResourceValidate[T any](opslevelResource T) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These function names are 😍 - Great Job! This one maybe should be IsResourceValid
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤣
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Amazing!
Issues
Changelog
Add
default:""
struct tags to:MemberInput
,PropertyDefinitionInput
,ToolCreateInput
,ToolUpdateInput
,UserInput
,UserIdentifierInput
Add
utils.go
with these functions:IsResourceValidate[T any](opslevelResource T)
- validates structs based onvalidate:""
struct tagsSetDefaultsFor[T any](opslevelResource *T)
- sets defaults defined bydefault:""
struct tagsNewExampleOf[T any]()
- generic constructor that sets defaults defined bydefault:""
struct tagsJsonOf[T any](opslevelResource T)
- converts struct to JSON formatted stringYamlOf[T any](opslevelResource T)
- converts struct to Yaml formatted stringIsResourceValidate
is not yet usedchangie
entryTophatting
task test
- tests pass