Skip to content

Commit

Permalink
add mode unmarshaller
Browse files Browse the repository at this point in the history
  • Loading branch information
ohaibbq committed Apr 11, 2024
1 parent 2afed39 commit a813184
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,18 @@ func (m *Mode) UnmarshalYAML(b []byte) error {
return nil
}

func (m *Mode) UnmarshalJSON(b []byte) error {
switch strings.ToLower(strings.Trim(string(b), `"`)) {
case strings.ToLower(string(NullableMode)):
*m = NullableMode
case strings.ToLower(string(RequiredMode)):
*m = RequiredMode
case strings.ToLower(string(RepeatedMode)):
*m = RepeatedMode
}
return nil
}

const (
NullableMode Mode = "NULLABLE"
RequiredMode Mode = "REQUIRED"
Expand Down

0 comments on commit a813184

Please sign in to comment.