mirror of
https://github.com/frosch95/SmartCSV.fx.git
synced 2026-04-11 13:38:23 +02:00
fixed uniqueness validation and renamed the abstract class when empty values are valid
This commit is contained in:
@@ -30,7 +30,7 @@ import static org.apache.commons.validator.GenericValidator.matchRegexp;
|
||||
/**
|
||||
* Checks if the value is alpha numeric
|
||||
*/
|
||||
public class AlphaNumericValidation extends EmptyAllowedValidation {
|
||||
public class AlphaNumericValidation extends EmptyValueIsValid {
|
||||
@Override
|
||||
public void check(int row, String value, ValidationError error) {
|
||||
if (!matchRegexp(value, "[0-9a-zA-Z]*")) {
|
||||
|
||||
@@ -30,7 +30,7 @@ import static org.apache.commons.validator.GenericValidator.isDate;
|
||||
/**
|
||||
* Checks if the date has the right format
|
||||
*/
|
||||
public class DateValidation extends EmptyAllowedValidation {
|
||||
public class DateValidation extends EmptyValueIsValid {
|
||||
|
||||
private String dateformat;
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ import static org.apache.commons.validator.GenericValidator.isDouble;
|
||||
/**
|
||||
* Checks if the value is a double
|
||||
*/
|
||||
public class DoubleValidation extends EmptyAllowedValidation {
|
||||
public class DoubleValidation extends EmptyValueIsValid {
|
||||
|
||||
@Override
|
||||
public void check(int row, String value, ValidationError error) {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package ninja.javafx.smartcsv.validation;
|
||||
|
||||
/**
|
||||
* Created by abi on 09.08.2016.
|
||||
* validations based on this are not validated when the value is null or empty
|
||||
*/
|
||||
public abstract class EmptyAllowedValidation implements Validation {
|
||||
public abstract class EmptyValueIsValid implements Validation {
|
||||
|
||||
@Override
|
||||
public boolean canBeChecked(String value) {
|
||||
@@ -33,7 +33,7 @@ import org.codehaus.groovy.control.CompilationFailedException;
|
||||
/**
|
||||
* Executes the given groovy as check
|
||||
*/
|
||||
public class GroovyValidation extends EmptyAllowedValidation {
|
||||
public class GroovyValidation extends EmptyValueIsValid {
|
||||
|
||||
private String groovyScript;
|
||||
private GroovyShell shell = new GroovyShell();
|
||||
|
||||
@@ -30,7 +30,7 @@ import static org.apache.commons.validator.GenericValidator.isInt;
|
||||
/**
|
||||
* Checks if the value is an integer
|
||||
*/
|
||||
public class IntegerValidation extends EmptyAllowedValidation {
|
||||
public class IntegerValidation extends EmptyValueIsValid {
|
||||
|
||||
@Override
|
||||
public void check(int row, String value, ValidationError error) {
|
||||
|
||||
@@ -30,7 +30,7 @@ import static org.apache.commons.validator.GenericValidator.maxLength;
|
||||
/**
|
||||
* Checks if the value is shorter or exactly as long as the given max length
|
||||
*/
|
||||
public class MaxLengthValidation extends EmptyAllowedValidation {
|
||||
public class MaxLengthValidation extends EmptyValueIsValid {
|
||||
|
||||
private int maxLength;
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ import static org.apache.commons.validator.GenericValidator.minLength;
|
||||
/**
|
||||
* Checks if the value is at minimum long as the given min length
|
||||
*/
|
||||
public class MinLengthValidation extends EmptyAllowedValidation {
|
||||
public class MinLengthValidation extends EmptyValueIsValid {
|
||||
|
||||
private int minLength;
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ import static org.apache.commons.validator.GenericValidator.matchRegexp;
|
||||
/**
|
||||
* Checks the value against the given reg exp
|
||||
*/
|
||||
public class RegExpValidation extends EmptyAllowedValidation {
|
||||
public class RegExpValidation extends EmptyValueIsValid {
|
||||
|
||||
private String regexp;
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ import static java.util.stream.Collectors.joining;
|
||||
/**
|
||||
* Checks if the value is unique in the column
|
||||
*/
|
||||
public class UniqueValidation extends EmptyAllowedValidation {
|
||||
public class UniqueValidation extends EmptyValueIsValid {
|
||||
|
||||
private ColumnValueProvider columnValueProvider;
|
||||
private String column;
|
||||
@@ -55,7 +55,7 @@ public class UniqueValidation extends EmptyAllowedValidation {
|
||||
for (int currentRowOfIteration = 0; currentRowOfIteration < numberOfRows; currentRowOfIteration++) {
|
||||
String storedValue = columnValueProvider.getValue(currentRowOfIteration, column);
|
||||
|
||||
if (storedValue.equals(value) && currentRowOfIteration != row) {
|
||||
if (value.equals(storedValue) && currentRowOfIteration != row) {
|
||||
lineNumbers.add(currentRowOfIteration + 1); // show not 0 based line numbers to user
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ import static java.util.stream.Collectors.joining;
|
||||
/**
|
||||
* Checks if the value is part of a list of values
|
||||
*/
|
||||
public class ValueOfValidation extends EmptyAllowedValidation {
|
||||
public class ValueOfValidation extends EmptyValueIsValid {
|
||||
|
||||
private List<String> values;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user