Skip to content

Commit

Permalink
Add RedPen#preValidate(Document)
Browse files Browse the repository at this point in the history
  • Loading branch information
takahi-i committed Oct 5, 2017
1 parent e66a6f2 commit ac7fd04
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
6 changes: 6 additions & 0 deletions redpen-core/src/main/java/cc/redpen/RedPen.java
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,12 @@ private void applyPreprocessorRules(List<Document> documents, Map<Document, List
}

private void runDocumentValidators(List<Document> documents, Map<Document, List<ValidationError>> docErrorsMap) {
// run Document PreProcessors to documents
for (Document document : documents) {
validators.forEach(e -> e.preValidate(document));
}

// run Section validator to documents
for (Document document : documents) {
List<ValidationError> errors = new ArrayList<>();
validators.forEach(e -> {e.setErrorList(errors); e.validate(document);});
Expand Down
9 changes: 9 additions & 0 deletions redpen-core/src/main/java/cc/redpen/validator/Validator.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,15 @@ public void preValidate(Sentence sentence) {
public void preValidate(Section section) {
}

/**
* Process input blocks before run validation. This method is used to store
* the information needed to run Validator before the validation process.
*
* @param document input document
*/
public void preValidate(Document document) {
}

/**
* validate the input document and returns the invalid points.
* {@link cc.redpen.validator.Validator} provides empty implementation. Validator implementation validates documents can override this method.
Expand Down

0 comments on commit ac7fd04

Please sign in to comment.