diff --git a/.gitignore b/.gitignore
index 5ff6309..f68d109 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,16 +1,7 @@
-target/
-!.mvn/wrapper/maven-wrapper.jar
-!**/src/main/**/target/
-!**/src/test/**/target/
-
### IntelliJ IDEA ###
-.idea/modules.xml
-.idea/jarRepositories.xml
-.idea/compiler.xml
-.idea/libraries/
-*.iws
-*.iml
-*.ipr
+out/
+!**/src/main/**/out/
+!**/src/test/**/out/
### Eclipse ###
.apt_generated
@@ -20,6 +11,9 @@ target/
.settings
.springBeans
.sts4-cache
+bin/
+!**/src/main/**/bin/
+!**/src/test/**/bin/
### NetBeans ###
/nbproject/private/
@@ -27,9 +21,6 @@ target/
/dist/
/nbdist/
/.nb-gradle/
-build/
-!**/src/main/**/build/
-!**/src/test/**/build/
### VS Code ###
.vscode/
diff --git a/.idea/.gitignore b/.idea/.gitignore
deleted file mode 100644
index 26d3352..0000000
--- a/.idea/.gitignore
+++ /dev/null
@@ -1,3 +0,0 @@
-# Default ignored files
-/shelf/
-/workspace.xml
diff --git a/.idea/encodings.xml b/.idea/encodings.xml
deleted file mode 100644
index aa00ffa..0000000
--- a/.idea/encodings.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
deleted file mode 100644
index 0a13117..0000000
--- a/.idea/misc.xml
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
deleted file mode 100644
index 35eb1dd..0000000
--- a/.idea/vcs.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/README.md b/README.md
index 31740e8..80a0fc0 100644
--- a/README.md
+++ b/README.md
@@ -1,13 +1,10 @@
-# CSV-Validation
+# CSV-Validation - Java 8
An example of how to reads a CSV file, validate the input data, and output the data to standard output. It performs validation on fields like **id**, **name**, **birthday**, **gender**, and **phone number** based on specific rules. The validated data is output along with error messages for invalid data. The header of the CSV file is excluded from validation.
There are only two classes in this project.
-[Main.java ](https://github.com/poralcode/CSV-Validation/blob/origin/src/main/java/Main.java "Main.java ")- The main class that contains the logic for reading the CSV file.
-[Validation.java](https://github.com/poralcode/CSV-Validation/blob/origin/src/main/java/Validation.java "Validation.java") - The class that provides validation logic for the fields in a CSV file.
-
-
-Unit Test: [ValidationTest.java](https://github.com/poralcode/CSV-Validation/blob/origin/src/test/java/ValidationTest.java "ValidationTest.java")
+[Main.java ](https://github.com/poralcode/CSV-Validation/blob/master/src/Main.java "Main.java ")- The main class that contains the logic for reading the CSV file.
+[Validation.java](https://github.com/poralcode/CSV-Validation/blob/master/src/Validation.java "Validation.java") - The class that provides validation logic for the fields in a CSV file.
------------
diff --git a/pom.xml b/pom.xml
deleted file mode 100644
index 2ac1c19..0000000
--- a/pom.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-
-
- 4.0.0
-
- org.example
- CSV-Validation
- 1.0-SNAPSHOT
-
-
- 20
- 20
- UTF-8
-
-
-
- org.junit.jupiter
- junit-jupiter
- RELEASE
- test
-
-
- junit
- junit
- 4.13.2
- test
-
-
-
-
\ No newline at end of file
diff --git a/src/main/java/Main.java b/src/main/java/Main.java
deleted file mode 100644
index a80d29b..0000000
--- a/src/main/java/Main.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Author: polarcode
- * Description: This program reads a CSV file, validates the input data, and outputs the data to standard output.
- * It performs validation on fields like id, name, birthday, gender, and phone number based on specific rules.
- * The validated data is output along with error messages for invalid data. The header of the CSV file is excluded
- * from validation.
- *
- * SAMPLE INPUT: writers.csv
- * id,name,birthday,gender,phone-number
- * 1,Liam,1980/02/29,male,09011112222
- * 2,Austin,1994/10/10,female,08033334444
- * 3,"Jonathan,Jr",1989/01/23,female,0355556666
- */
-
-import java.io.BufferedReader;
-import java.io.FileReader;
-import java.io.IOException;
-import java.util.logging.*;
-
-public class Main {
- private static final Logger LOGGER = Logger.getLogger(Main.class.getName());
- public static void main(String[] args) {
- String csvFilePath = "writers.csv"; //File Path of CSV file.
-
- try (BufferedReader br = new BufferedReader(new FileReader(csvFilePath))) {
- String header = br.readLine(); // Read and print the header
- System.out.println(header); //print the header as-is.
- br.lines()
- .map(line -> line.split(",(?=([^\"]*\"[^\"]*\")*[^\"]*$)", -1))
- .map(Main::validateFields) //Validate each field in the line.
- .forEach(System.out::println); //Print the validated line.
- } catch (IOException e) {
- LOGGER.log(Level.SEVERE, "An error occurred while reading the CSV file", e);
- }
- }
-
- private static String validateFields(String[] fields) {
- StringBuilder outputLine = new StringBuilder();
-
- for (int i = 0; i < fields.length; i++) { //We loop through the fields on the line.
- String fieldValue = fields[i];
- String validatedValue = Validation.validateField(i, fieldValue);
- if (i > 0)
- outputLine.append(",");
- outputLine.append(validatedValue);
- }
- return outputLine.toString(); //return the validated line.
- }
-}
\ No newline at end of file
diff --git a/src/main/java/Validation.java b/src/main/java/Validation.java
deleted file mode 100644
index a7039a9..0000000
--- a/src/main/java/Validation.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Validation Class
- * Author: polarcode
- * Description: This class provides validation logic for the fields in a CSV file. It performs checks for id, name,
- * birthday, gender, and phone number based on specific rules. If the validation fails, appropriate error messages
- * are returned. If validation passes, the original value is returned.
- */
-
-import java.util.regex.Pattern;
-
-public class Validation {
-
- //Based on the outline, we only have 3 different error message. It's better to put it into string array.
- private static final String[] validationErrors = {
- "Error required",
- "Error limit over",
- "Error format"
- };
-
- public static String validateField(int index, String value) {
- return switch (index) {
- case 0 -> // id
- value.matches("\\d+") ? value : validationErrors[2];
- case 1 -> { // name
- if (value.isEmpty())
- yield validationErrors[0];
- yield value.length() > 100 ? validationErrors[1] : value;
- }
- case 2 -> { // birthday
- if (value.isEmpty())
- yield validationErrors[0];
- yield Pattern.matches("\\d{4}(/|-)\\d{2}(/|-)\\d{2}", value) ? value : validationErrors[2];
- }
- case 3 -> // gender
- (!value.isEmpty() && value.matches("(?i)male|female")) ? value : validationErrors[2];
- case 4 -> { // phone-number
- if (value.isEmpty())
- yield validationErrors[0];
- yield Pattern.matches("\\d{3}(-|\\s)?\\d{3,4}(-|\\s)?\\d{4}|\\d{4}-\\d{2}-\\d{4}|\\d{10,11}", value) ? value : validationErrors[2];
- }
- default -> value;
- };
- }
-}
\ No newline at end of file
diff --git a/src/test/java/ValidationTest.java b/src/test/java/ValidationTest.java
deleted file mode 100644
index 1167468..0000000
--- a/src/test/java/ValidationTest.java
+++ /dev/null
@@ -1,60 +0,0 @@
-import org.junit.Test;
-import static org.junit.jupiter.api.Assertions.*;
-
-public class ValidationTest {
-
- @Test
- public void testValidateFieldId() {
- String result = Validation.validateField(0, "123");
- assertEquals("123", result);
- }
-
- @Test
- public void testValidateFieldNameEmpty() {
- String result = Validation.validateField(1, "");
- assertEquals("Error required", result);
- }
-
- @Test
- public void testValidateFieldNameTooLong() {
- String name = "ThisIsAReallyLongNameThatExceedsTheMaximumLengthAllowedByValidation";
- String result = Validation.validateField(1, name);
- assertEquals(name, result);
- }
-
- @Test
- public void testValidateFieldBirthdayValid() {
- String result = Validation.validateField(2, "1980/02/29");
- assertEquals("1980/02/29", result);
- }
-
- @Test
- public void testValidateFieldBirthdayInvalid() {
- String result = Validation.validateField(2, "02/29/1980");
- assertEquals("Error format", result);
- }
-
- @Test
- public void testValidateFieldGenderValid() {
- String result = Validation.validateField(3, "female");
- assertEquals("female", result);
- }
-
- @Test
- public void testValidateFieldGenderInvalid() {
- String result = Validation.validateField(3, "unknown");
- assertEquals("Error format", result);
- }
-
- @Test
- public void testValidateFieldPhoneNumberValid() {
- String result = Validation.validateField(4, "09011112222");
- assertEquals("09011112222", result);
- }
-
- @Test
- public void testValidateFieldPhoneNumberInvalid() {
- String result = Validation.validateField(4, "invalidPhoneNumber");
- assertEquals("Error format", result);
- }
-}