Skip to content

Add new Number and Temporal type validations - #10

Merged
ThoSap merged 4 commits into
mainfrom
add-number-and-date-types
Jan 13, 2025
Merged

Add new Number and Temporal type validations#10
ThoSap merged 4 commits into
mainfrom
add-number-and-date-types

Conversation

@ThoSap

@ThoSap ThoSap commented Jan 10, 2025

Copy link
Copy Markdown
Member

This PR adds the following new types for the Number and Temporal validations:

  • Number
    • Byte (byte)
    • Short (short)
    • BigInteger
  • Temporal
    • Instant
    • LocalTime
    • OffsetTime
    • Year
    • YearMonth
    • ZonedDateTime

It also refactors the code in LessThanValueSource and BiggerThanValueSource, as

new Random().<numberType>(<numberType> randomNumberOrigin, <numberType> randomNumberBound).limit(1)

can be replaced with

new Random().<numberType>(long streamSize /* 1 */, <numberType> randomNumberOrigin, <numberType> randomNumberBound)

and doing our own bounds calculation in LessThanValueSource methods getFloatStream, getDoubleStream, getBigDecimalStream and getScaledBigDecimalStream using

new Random().doubles(1).map(d -> minValue + (maxValue - minValue) * d)

is not necessary as the following signature exists:

DoubleStream doubles(long streamSize /* 1 */, double randomNumberOrigin /* inclusive */, double randomNumberBound /* exclusive */)

@ThoSap
ThoSap requested a review from SirCotare January 10, 2025 11:28
@ThoSap ThoSap self-assigned this Jan 10, 2025

@SirCotare SirCotare left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

well done! 👍

@ThoSap
ThoSap merged commit f165ea4 into main Jan 13, 2025
@ThoSap
ThoSap deleted the add-number-and-date-types branch January 13, 2025 08:05
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.

2 participants