@Test void testSimpleRun() throws RedPenException { Configuration config = Configuration.builder() .addValidatorConfig(new ValidatorConfiguration("InvalidExpression").addProperty("list", "may")) .build(); Validator validator = ValidatorFactory.getInstance(config.getValidatorConfigs().get(0), config); List<ValidationError> errors = new ArrayList<>(); validator.setErrorList(errors); validator.validate(new Sentence("The experiments may be true.", 0)); assertEquals(1, errors.size()); }
@Override public void validate(Sentence sentence) { streamDictionary().forEach(value -> { int startPosition = sentence.getContent().indexOf(value); if (startPosition != -1) { addLocalizedErrorWithPosition(sentence, startPosition, startPosition + value.length(), value); } }); }
InvalidExpressionValidator extends DictionaryValidator { @Override public void validate(Sentence sentence) { streamDictionary().forEach(value -> { int startPosition = sentence.getContent().indexOf(value); if (startPosition != -1) { addLocalizedErrorWithPosition(sentence, startPosition, startPosition + value.length(), value); } }); } }
InvalidExpressionValidator extends DictionaryValidator { @Override public void validate(Sentence sentence) { streamDictionary().forEach(value -> { int startPosition = sentence.getContent().indexOf(value); if (startPosition != -1) { addLocalizedErrorWithPosition(sentence, startPosition, startPosition + value.length(), value); } }); } InvalidExpressionValidator(); }
InvalidExpressionValidator extends DictionaryValidator { @Override public void validate(Sentence sentence) { streamDictionary().forEach(value -> { int startPosition = sentence.getContent().indexOf(value); if (startPosition != -1) { addLocalizedErrorWithPosition(sentence, startPosition, startPosition + value.length(), value); } }); } InvalidExpressionValidator(); @Override void validate(Sentence sentence); }
InvalidExpressionValidator extends DictionaryValidator { @Override public void validate(Sentence sentence) { streamDictionary().forEach(value -> { int startPosition = sentence.getContent().indexOf(value); if (startPosition != -1) { addLocalizedErrorWithPosition(sentence, startPosition, startPosition + value.length(), value); } }); } InvalidExpressionValidator(); @Override void validate(Sentence sentence);  }