All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog and this project adheres to Semantic Versioning.
- New constrainedTo() function: Introduced a new function to apply constraints to the result of an operation, returning the result if it satisfies the constraints or throwing an exception otherwise.
BeNull
Constraint: Added a new constraint to validate if a value isnull
.
- Migration to KMP: The library has been migrated to Kotlin Multiplatform (KMP) to support cross-platform development.
- Updated Kotlin Version: Upgraded the Kotlin version to
2.0.0
to align with the latest language features and improvements.
- Custom Exception Specification for Constraints is now stable and no longer experimental.
CompositeException
now displays the source exception's class name in the message for better readability.
- [EXPERIMENTAL]
BeFinite
Constraint:- Introduced the
BeFinite
object in thecl.ravenhill.jakt.constraints.doubles
package. - This new constraint implements the
DoubleConstraint
interface and is designed to check if a givenDouble
value is finite. - The primary purpose is to enhance the validation capabilities for
Double
values, ensuring they are neither infinite norNaN
.
- Introduced the
- [EXPERIMENTAL]
BeInfinite
Double Constraint:- Introduced the
BeInfinite
data object in theconstraints.doubles
package. - This constraint is designed to validate whether a
Double
value is infinite (either positive or negative infinity). - It serves as a crucial tool for scenarios involving mathematical computations or simulations where the concept of infinity is relevant, such as in cases of overflow.
- Introduced the
- [EXPERIMENTAL]
BeNaN
Double Constraint:- Introduced the
BeNaN
data object within the library, specifically for validating if aDouble
value is NaN (Not a Number). - This new feature significantly enhances the library's capabilities by enabling the detection of NaN values in numerical computations, which is crucial for accurate and reliable data validation in mathematical and scientific applications.
- Introduced the
- [EXPERIMENTAL] #1 Custom Exception Specification for Constraints
-
BePositive
Constraint:- [EXPERIMENTAL] Introduced the
BePositive
constraint for validating positive double values. This new constraint enhances the library's capabilities in handling numerical validations.
- [EXPERIMENTAL] Introduced the
-
ExperimentalJakt Annotation:
- Introduced the
ExperimentalJakt
annotation as a marker for experimental features within the Jakt project. This annotation helps in identifying features that are still in the experimental phase and may be subject to change.
- Introduced the
- Kotlin Version Update:
- Downgraded the Kotlin version to
1.9.21
to resolve compatibility issues.
- Downgraded the Kotlin version to
- Updated Dependencies:
- Kotest: Upgraded the Kotest framework for assertions, properties, and junit5 runner to their latest versions. Adjustments made in configuration files to align with the new versions.
- Dokka Plugin: Updated to its newer version. Configuration files modified to accommodate changes in the plugin.
- Detekt Plugin: Upgraded to the latest version. Necessary adjustments made in the respective configuration files.
shortCircuit
flag to stop evaluating constraints after the first failure.- New String Validation Constraints:
BeAlphanumeric
: Validates if a string contains only alphanumeric characters.BeEmpty
: Checks if a string is empty.Contain
: Ensures a string matches a specified regular expression.
- Test Suites for String Constraints:
BeAlphanumericTest
for validating alphanumeric strings.BeEmptyTest
for validating empty strings.ContainTest
for validating strings against regular expressions.
BeMonotonicallyIncreasing
Constraint: Validates that a collection of elements is monotonically increasing, useful for sorted lists and sequences.- Special Characters Generator in
Strings
(datatypes): Facilitates creating test datasets with non-alphanumeric characters. BeMonotonicallyDecreasing
Constraint:- A new constraint designed to validate if a collection of elements is monotonically decreasing.
- Useful in scenarios such as verifying sorted arrays in descending order.
BeMonotonicallyDecreasingTest
:- A test suite developed to ensure the correctness of the
BeMonotonicallyDecreasing
constraint under various conditions.
- A test suite developed to ensure the correctness of the
BeAtLeast
Constraint:- A new constraint for checking if a numerical value (both Double and Int) is at least a specified minimum.
- Accompanied by test suites to ensure functionality for both Double and Int types.
BeAtMost
Constraint:- A new constraint for validating whether a value is less than or equal to a specified maximum.
- Useful for enforcing upper limits in various calculations, settings, or measurements.
BeNegativeConstraint
- A new constraint for checking if a comparable value is negative.
- Useful for ensuring that a value is less than "zero".
BePositiveConstraint
- A new constraint for checking if a comparable value is positive.
- Useful for ensuring that a value is greater than "zero".
- Obsolete Pair Constraints:
BeFinite.kt
BeStrictlyOrdered.kt
PairConstraint.kt
- Corresponding tests for these constraints.
- Project Settings Files: Adjustments made for improved project configuration.
CollectionConstraint
Refactoring:- Enhanced to support generic collections.
- Replaced wildcards with generic types for increased type safety and to avoid unexpected behaviors.
- Refactored
BeInRange
Constraint:- Updated for better extensibility and ease of future enhancements.
- Documentation:
BeAlphanumeric
andBeEmpty
classes now have enhanced documentation for better readability and comprehension.
JaktTest
Enhancements:- Added assertions to verify the
BeEqualTo
constraint behavior. - Included comprehensive tests for
CompositeException
handling. - Assured correct application of constraints and appropriate exception handling.
- Added assertions to verify the
- Testing Structure:
- Refactored existing tests by introducing a generic function for constraint validation.
- Updated test cases to align with the new testing approach.
- This improvement focuses on enhancing code reusability and readability in tests.
- Predicate support to the
HaveSize
constraint for more flexible collection size checks. - A
CHANGELOG
file to the project for documenting changes per industry standards.
- The
CompositeException
to ensure that it is only thrown when there is at least one exception present.
- The
Ranges
utility class to simplify its implementation.
- Deprecated functions from the
Ranges
utility class.
- Moved the
Ranges
utility class to an appropriate package to better reflect its usage within the project.