Skip to content

Conversation

@abemedia
Copy link
Contributor

@abemedia abemedia commented Jul 11, 2025

Add support for format: decimal for types number and string using https://github.com/shopspring/decimal (the most widely used Go package for decimals, see https://pkg.go.dev/search?q=decimal).

Closes #1478

@abemedia abemedia force-pushed the feat/decimal-format branch 4 times, most recently from d53c3bc to 4ce54f3 Compare July 11, 2025 11:11
return typePrefix("UnixMicro")
case "unix-milli":
return typePrefix("UnixMilli")
case "decimal": //nolint:goconst // This whole switch is duplicated in NamePostfix. Should create a common helper.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See code comment. Will clean up to remove duplication of this switch in a separate PR. Just didn't want to pollute this one too much.

If you don't mind unrelated refactor going in this feature I can fix it on this PR though.

Comment on lines +28 to +38
// SetExclusiveMinimum sets exclusive minimum value.
func (t *Decimal) SetExclusiveMinimum(v decimal.Decimal) {
t.MinExclusive = true
t.SetMinimum(v)
}

// SetExclusiveMaximum sets exclusive maximum value.
func (t *Decimal) SetExclusiveMaximum(v decimal.Decimal) {
t.MaxExclusive = true
t.SetMaximum(v)
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I included these to match the float validator, although they actually aren't used anywhere (neither here nor float). Shall I remove?

@abemedia abemedia marked this pull request as ready for review July 11, 2025 11:54
@ernado
Copy link
Member

ernado commented Sep 16, 2025

Hey @abemedia, please resolve conflicts

@abemedia abemedia force-pushed the feat/decimal-format branch from 4ce54f3 to 29a7e27 Compare October 5, 2025 07:52
@abemedia
Copy link
Contributor Author

abemedia commented Oct 5, 2025

@ernado I have resolved conflicts.

@ernado ernado merged commit fb3210d into ogen-go:main Oct 5, 2025
15 checks passed
@abemedia abemedia deleted the feat/decimal-format branch October 5, 2025 11:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

gen: Support format decimal

2 participants