FileFormatValidator 1.0 Help

How to use

Make sure that:

  • File format validator artifacts are in your project

Creation of a Format Validator Instance

  1. Create a List to hold all rules to be added to the Format Validator Object

    List<LineValidationRule> lineValidationRules = new ArrayList<>();
  2. Start defining validation rules and add them to the list

    Line validation rules

    • Existing validation rule for Line length. In this example it is being create a rule to validate the length of the line is equal to 10

      LineValidationRule lengthValidation = new LineLengthValidationRule(10); lineValidationRules.add(lengthValidation);
    • Existing validation rule to verify is the text line has a certain field separator. In this example the rule is being defined to verify for pipe "|" separator

      LineFieldSeparatorValidationRule pipeSeparatorValidationRule = new LineFieldSeparatorValidationRule("|"); lineValidationRules.add(pipeSeparatorValidationRule);
  3. Create the FileValidator by passing the list of validation rules to constructor

    FileValidator validator = new FileValidator(lineValidationRules);
  4. Validate the file by passing the filePath to the validate method

    validator.validate("fileToValidate.txt")
Last modified: 20 October 2024