Skip to content
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 isLocalDate to CharSequenceConstraint #283

Merged
merged 5 commits into from
Nov 21, 2022
Merged

Conversation

ffroliva
Copy link
Contributor

@ffroliva ffroliva commented Nov 3, 2022

Hi this pull request addes isLocalDate validation in CharSequenceConstraint. This validates if a given string is in ISO format or in a given pattern format.

@ffroliva
Copy link
Contributor Author

ffroliva commented Nov 9, 2022

Any updates on this?

@@ -182,6 +185,22 @@ private <U> CharSequenceConstraint<T, E> isValidRepresentationOf(
return this;
}

/**
* @since 0.11.3
Copy link
Owner

Choose a reason for hiding this comment

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

0.12.0

* @since 0.11.3
*/
public CharSequenceConstraint<T, E> isLocalDate() {
return this.isValidLocalDate("yyyy-MM-dd");
Copy link
Owner

Choose a reason for hiding this comment

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

uuuu-MM-dd

private CharSequenceConstraint<T, E> isValidLocalDate(String pattern) {
this.predicates().add(ConstraintPredicate.of(x -> {
try {
LocalDate.parse(x, DateTimeFormatter.ofPattern(pattern));
Copy link
Owner

Choose a reason for hiding this comment

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

DateTimeFormatter.ofPattern(pattern, locale).withResolverStyle(ResolverStyle.STRICT)

@@ -238,6 +257,20 @@ public CharSequenceConstraint<T, E> isBigDecimal() {
return this.isValidRepresentationOf(BigDecimal::new, CHAR_SEQUENCE_BIGDECIMAL);
}

/**
* @since 0.11.3
Copy link
Owner

Choose a reason for hiding this comment

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

0.12.0

}

/**
* @since 0.11.3
Copy link
Owner

Choose a reason for hiding this comment

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

0.12.0

/**
* @since 0.11.3
*/
public CharSequenceConstraint<T, E> isLocalDate() {
Copy link
Owner

Choose a reason for hiding this comment

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

isIsoLocalDate

/**
* @since 0.11.3
*/
private CharSequenceConstraint<T, E> isValidLocalDate(String pattern) {
Copy link
Owner

Choose a reason for hiding this comment

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

isValidLocalDate(String pattern, Locale locale)

@making making added this to the 0.12.0 milestone Nov 17, 2022
@making making added the enhancement New feature or request label Nov 17, 2022
@making
Copy link
Owner

making commented Nov 21, 2022

@ffroliva
Can I make changes directly and merge them?

@making making merged commit 3e33f49 into making:develop Nov 21, 2022
@making
Copy link
Owner

making commented Nov 21, 2022

@ffroliva Thanks for your contribution!

@ffroliva
Copy link
Contributor Author

It was my pleasure!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants