Skip to content

Commit

Permalink
add validator.js example
Browse files Browse the repository at this point in the history
  • Loading branch information
yusuke committed Jul 14, 2015
1 parent 258d496 commit d4755ce
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 0 deletions.
1 change: 1 addition & 0 deletions redpen-cli/sample/conf/redpen-conf-en.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@
<validator name="SuccessiveWord" />
<validator name="EndOfSentence" />
<validator name="SpaceBeginningOfSentence" />
<validator name="JavaScript" />
</validators>
</redpen-conf>
1 change: 1 addition & 0 deletions redpen-cli/sample/conf/redpen-conf-ja.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@
<validator name="SpaceBetweenAlphabeticalWord" />
<validator name="CommaNumber" />
<validator name="SuccessiveWord" />
<validator name="JavaScript" />
</validators>
</redpen-conf>
22 changes: 22 additions & 0 deletions redpen-cli/sample/js/validator.js.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
var message = "word [{0}] is too long. length: {1}";

function validateSentence(sentence) {
var content = sentence.getContent().split(" ");
for(var i = 0; i<content.length;i++){
if(content[i].length >= 10){
addValidationError(sentence, content[i], content[i].length);
}
}
}

// optionally, you can implement validation logic for document, section
/*
function preValidateSentence(sentence) {
}
function preValidateSection(section) {
}
function validateDocument(document) {
}
function validateSection(section) {
}
*/
7 changes: 7 additions & 0 deletions redpen-cli/src/main/assembly/executable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@
<include>**/*</include>
</includes>
</fileSet>
<fileSet>
<directory>sample/js</directory>
<outputDirectory>/js</outputDirectory>
<includes>
<include>**/*</include>
</includes>
</fileSet>
<fileSet>
<directory>sample/sample-doc</directory>
<outputDirectory>/sample-doc</outputDirectory>
Expand Down

0 comments on commit d4755ce

Please sign in to comment.