-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
incrementa validacoes para o campo year #5710
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
package org.jabref.logic.integrity; | ||
|
||
import java.util.Calendar; | ||
import java.util.Optional; | ||
import java.util.function.Predicate; | ||
import java.util.regex.Pattern; | ||
|
@@ -23,6 +24,10 @@ public class YearChecker implements ValueChecker { | |
*/ | ||
@Override | ||
public Optional<String> checkValue(String value) { | ||
char [] C_value = value.toCharArray(); | ||
Calendar cal = Calendar.getInstance(); | ||
int ActualYear = cal.get(Calendar.YEAR); | ||
|
||
if (StringUtil.isBlank(value)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should be the first statement in the method |
||
return Optional.empty(); | ||
} | ||
|
@@ -35,6 +40,14 @@ public Optional<String> checkValue(String value) { | |
return Optional.of(Localization.lang("last four nonpunctuation characters should be numerals")); | ||
} | ||
|
||
if(!Character.isDigit(C_value[0])){ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you use Eclipse or IntelliJ? In IntelliJ, we have custom format rules: https://github.com/JabRef/jabref/wiki/Guidelines-for-setting-up-a-local-workspace#intellij. Maybe, we generate the Eclipse rules also at |
||
return Optional.of(Localization.lang("First character should be numeral")); | ||
} | ||
|
||
if(ActualYear < Integer.parseInt(value)) { | ||
return Optional.of(Localization.lang("Year should be smaller or equal then actual year")); | ||
} | ||
|
||
return Optional.empty(); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
char[]
seems to be very old school.