@Test void testJapaneseCornerCase() throws RedPenException { Configuration config = Configuration.builder("ja") .addValidatorConfig(new ValidatorConfiguration("CommaNumber")) .build(); Validator validator = ValidatorFactory.getInstance(config.getValidatorConfigs().get(0), config); List<ValidationError> errors = new ArrayList<>(); validator.setErrorList(errors); validator.validate(new Sentence("しかし、この仕組みで背中を押した結果、挑戦できない人は、ゴールに到達するためのタスクに挑戦するようになりました。", 0)); assertEquals(0, errors.size()); }
@Override public void validate(Sentence sentence) { String content = sentence.getContent(); int commaCount = 0; int position = 0; while ((position = content.indexOf(this.comma)) != -1) { commaCount++; content = content.substring(position + 1, content.length()); } if (getMaxNum() < commaCount) { addLocalizedError(sentence, commaCount, getMaxNum()); } }
CommaNumberValidator extends Validator { @Override public void validate(Sentence sentence) { String content = sentence.getContent(); int commaCount = 0; int position = 0; while ((position = content.indexOf(this.comma)) != -1) { commaCount++; content = content.substring(position + 1, content.length()); } if (getMaxNum() < commaCount) { addLocalizedError(sentence, commaCount, getMaxNum()); } } }
CommaNumberValidator extends Validator { @Override public void validate(Sentence sentence) { String content = sentence.getContent(); int commaCount = 0; int position = 0; while ((position = content.indexOf(this.comma)) != -1) { commaCount++; content = content.substring(position + 1, content.length()); } if (getMaxNum() < commaCount) { addLocalizedError(sentence, commaCount, getMaxNum()); } } CommaNumberValidator(); }
CommaNumberValidator extends Validator { @Override public void validate(Sentence sentence) { String content = sentence.getContent(); int commaCount = 0; int position = 0; while ((position = content.indexOf(this.comma)) != -1) { commaCount++; content = content.substring(position + 1, content.length()); } if (getMaxNum() < commaCount) { addLocalizedError(sentence, commaCount, getMaxNum()); } } CommaNumberValidator(); @Override void validate(Sentence sentence); }
CommaNumberValidator extends Validator { @Override public void validate(Sentence sentence) { String content = sentence.getContent(); int commaCount = 0; int position = 0; while ((position = content.indexOf(this.comma)) != -1) { commaCount++; content = content.substring(position + 1, content.length()); } if (getMaxNum() < commaCount) { addLocalizedError(sentence, commaCount, getMaxNum()); } } CommaNumberValidator(); @Override void validate(Sentence sentence);  }