{"record":{"id":"59012d338cbd82a6","repo":"languagetool-org/languagetool","slug":"set-only-weekday-and-date-for-dmydatecheck","errorCode":null,"errorMessage":"Set only 'weekDay' and 'date' for \" + DMYDateCheckFilter.class.getSimpleName()","messagePattern":"Set only 'weekDay' and 'date' for \" \\+ DMYDateCheckFilter\\.class\\.getSimpleName\\(\\)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"languagetool-language-modules/fr/src/main/java/org/languagetool/rules/fr/DMYDateCheckFilter.java","lineNumber":36,"sourceCode":" */\npackage org.languagetool.rules.fr;\n\nimport org.languagetool.AnalyzedTokenReadings;\nimport org.languagetool.rules.RuleMatch;\n\nimport java.util.List;\nimport java.util.Map;\n\n/**\n * Date filter that expects a 'date' argument in the format 'dd-mm-yyyy'.\n * @since 2.7\n */\npublic class DMYDateCheckFilter extends DateCheckFilter {\n\n  @Override\n  public RuleMatch acceptRuleMatch(RuleMatch match, Map<String, String> args, int patternTokenPos, AnalyzedTokenReadings[] patternTokens, List<Integer> tokenPositions) {\n    if (args.containsKey(\"year\") || args.containsKey(\"month\") || args.containsKey(\"day\")) {\n      throw new RuntimeException(\"Set only 'weekDay' and 'date' for \" + DMYDateCheckFilter.class.getSimpleName());\n    }\n    String dateString = getRequired(\"date\", args);\n    String[] parts = dateString.split(\"-\");\n    if (parts.length != 3) {\n      throw new RuntimeException(\"Expected date in format 'dd-mm-yyyy': '\" + dateString + \"'\");\n    }\n    args.put(\"day\", parts[0]);\n    args.put(\"month\", parts[1]);\n    args.put(\"year\", parts[2]);\n    return super.acceptRuleMatch(match, args, patternTokenPos, patternTokens, tokenPositions);\n  }\n\n}\n","sourceCodeStart":18,"sourceCodeEnd":50,"githubUrl":"https://github.com/languagetool-org/languagetool/blob/2e990059ce67d5e2a0f7f7ca5d31160c6709df4b/languagetool-language-modules/fr/src/main/java/org/languagetool/rules/fr/DMYDateCheckFilter.java#L18-L50","documentation":"DMYDateCheckFilter parses a French 'dd-mm-yyyy' date and then delegates to DateCheckFilter by filling in day/month/year args. This RuntimeException is thrown when a XML rule supplies 'year', 'month' or 'day' arguments, which this filter does not support; it only accepts 'weekDay' and 'date'. It exists to fail fast on misconfigured grammar rules instead of silently ignoring conflicting args.","triggerScenarios":"acceptRuleMatch is invoked during rule evaluation of a pattern rule whose <filter class=\"...DMYDateCheckFilter\"> element declares args 'year', 'month' and/or 'day'. Any one of those keys in the args map triggers the throw immediately, before any date parsing.","commonSituations":"Authors copy an argument set from DMYDateCheckFilter's parent DateCheckFilter (which does accept year/month/day) into a French rule; rule XML refactors leave stale 'day'/'month'/'year' attributes; mixing up the two filters when converting an existing date rule.","solutions":["Remove the 'year', 'month' and 'day' attributes from the <filter> element in the rule XML.","Express the date as a single 'date' attribute in dd-mm-yyyy form, optionally with 'weekDay'.","If you truly need explicit year/month/day values, use the parent DateCheckFilter class instead of DMYDateCheckFilter."],"exampleFix":"<!-- before -->\n<filter class=\"org.languagetool.rules.fr.DMYDateCheckFilter\" args=\"date:25-12-2024 year:2024\"/>\n<!-- after -->\n<filter class=\"org.languagetool.rules.fr.DMYDateCheckFilter\" args=\"date:25-12-2024\"/>","handlingStrategy":"validation","validationCode":"// before evaluating a rule with this filter\nSet<String> forbidden = Set.of(\"year\", \"month\", \"day\");\nif (args.keySet().stream().anyMatch(forbidden::contains)) {\n    throw new IllegalArgumentException(\"DMYDateCheckFilter accepts only 'weekDay' and 'date'\");\n}","typeGuard":null,"tryCatchPattern":"try { filter.acceptRuleMatch(match, args, pos, tokens, tokenPositions); } catch (RuntimeException e) { LOG.error(\"Bad date-filter config: \" + e.getMessage(), e); }","preventionTips":["Keep DMYDateCheckFilter args limited to 'weekDay' and 'date' in rule XML.","Use DateCheckFilter when explicit year/month/day values are needed.","Lint rule XML filter args against each filter's supported keys in CI."],"tags":["java","languagetool","rule-configuration","french"],"backgroundTag":"mutually-exclusive-options","analyzedSha":"2e990059ce67d5e2a0f7f7ca5d31160c6709df4b","analyzedAt":"2026-09-06T09:20:17.015Z","contentChangedAt":"2026-09-06T09:20:17.015Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}