public bool validate() { //checking validity of header string header = fileReader.ReadLine(); this.isHeaderValid = true; if (!validHeader(header)) { this.errorType = "HeaderInvalid"; this.errorLine = 1; this.isHeaderValid = false; return(false); } Console.WriteLine("the number of columns is " + this.numberOfColumns); FormatValidator formatValidator = new FormatValidator(this.numberOfColumns); FieldValueExtractor fieldValue = new FieldValueExtractor(); fieldValue.setNumberOfField(this.numberOfColumns); data.Add(fieldValue.parseLine(header)); //checking validity of data field string temp; string[] tempRowField; while ((temp = fileReader.ReadLine()) != null) { if (formatValidator.isLineFormatValid(temp) == true) { tempRowField = formatValidator.getRowField(); if (FieldValidator.isLineFieldValid(tempRowField) == true) { data.Add(fieldValue.parseLine(temp)); //return true; } else { errorType = "FieldInvalid"; errorLine = data.Count + 1; return(false); } } else { errorType = "FormatInvalid"; errorLine = data.Count + 1; return(false); } } return(true); }
public bool validate() { //checking validity of header string header = fileReader.ReadLine(); this.isHeaderValid = true; if (!validHeader(header)) { this.errorType = "HeaderInvalid"; this.errorLine = 1; this.isHeaderValid = false; return false; } Console.WriteLine("the number of columns is "+this.numberOfColumns); FormatValidator formatValidator= new FormatValidator(this.numberOfColumns); FieldValueExtractor fieldValue = new FieldValueExtractor(); fieldValue.setNumberOfField(this.numberOfColumns); data.Add(fieldValue.parseLine(header)); //checking validity of data field string temp; string[] tempRowField; while ((temp = fileReader.ReadLine()) != null) { if (formatValidator.isLineFormatValid(temp) == true) { tempRowField = formatValidator.getRowField(); if (FieldValidator.isLineFieldValid(tempRowField) == true) { data.Add(fieldValue.parseLine(temp)); //return true; } else { errorType = "FieldInvalid"; errorLine = data.Count+1; return false; } } else { errorType = "FormatInvalid"; errorLine = data.Count+1; return false; } } return true; }