{"record":{"id":"7e5ae5bdf136db91","repo":"jhy/jsoup","slug":"must-be-false","errorCode":null,"errorMessage":"Must be false","messagePattern":"Must be false","errorType":"validation","errorClass":"ValidationException","httpStatus":null,"severity":"error","filePath":"src/main/java/org/jsoup/helper/Validate.java","lineNumber":103,"sourceCode":"    /**\n     * Validates that the value is true\n     * @param val object to test\n     * @param msg message to include in the Exception if validation fails\n     * @throws ValidationException if the object is not true\n     */\n    public static void isTrue(boolean val, String msg) {\n        if (!val)\n            throw new ValidationException(msg);\n    }\n\n    /**\n     * Validates that the value is false\n     * @param val object to test\n     * @throws ValidationException if the object is not false\n     */\n    public static void isFalse(boolean val) {\n        if (val)\n            throw new ValidationException(\"Must be false\");\n    }\n\n    /**\n     * Validates that the value is false\n     * @param val object to test\n     * @param msg message to include in the Exception if validation fails\n     * @throws ValidationException if the object is not false\n     */\n    public static void isFalse(boolean val, String msg) {\n        if (val)\n            throw new ValidationException(msg);\n    }\n\n    /**\n     * Validates that the array contains no null elements\n     * @param objects the array to test\n     * @throws ValidationException if the array contains a null element\n     */","sourceCodeStart":85,"sourceCodeEnd":121,"githubUrl":"https://github.com/jhy/jsoup/blob/9851ac5d9c576c6888910b5a51a2362bbc978959/src/main/java/org/jsoup/helper/Validate.java#L85-L121","documentation":"Validate.isFalse(val) is the mirror of isTrue: it throws ValidationException(\"Must be false\") when the supplied boolean condition is true. It enforces negative preconditions, i.e. states that must not hold.","triggerScenarios":"Code that asserts something must NOT be the case — e.g. an element must not already exist, a flag must not be set, or a parsed value must not indicate an error condition — and the condition is in fact true at runtime.","commonSituations":"Guard clauses against duplicate inserts or forbidden states in code built on jsoup's Validate; document states the author assumed impossible but that malformed input produced.","solutions":["Evaluate the forbidden condition yourself before the call and take the appropriate branch","Fix whatever state caused the condition to become true","Use isFalse(val, msg) to record which negative invariant was violated"],"exampleFix":"// before\nValidate.isFalse(doc.getElementsByTag(\"script\").isEmpty() == false); // scripts present\n// after\nif (doc.getElementsByTag(\"script\").isEmpty()) { process(doc); }\nelse { sanitize(doc); }","handlingStrategy":"validation","validationCode":"if (forbiddenCondition) {\n    // remediate: deduplicate, sanitize, or reject before the guarded call\n    return;\n}","typeGuard":null,"tryCatchPattern":"try {\n    guardedOperation();\n} catch (ValidationException e) {\n    if (e.getMessage().equals(\"Must be false\")) {\n        log.warn(\"Forbidden state detected; skipping\");\n    } else { throw e; }\n}","preventionTips":["Check for forbidden states (duplicates, error markers) before calling guarded APIs","Use isFalse(val, msg) to name the violated invariant","Handle malformed input that can make the 'impossible' condition true"],"tags":["assertion","validation","boolean"],"backgroundTag":"invalid-argument-value","analyzedSha":"9851ac5d9c576c6888910b5a51a2362bbc978959","analyzedAt":"2026-09-08T15:22:04.931Z","contentChangedAt":"2026-09-08T15:22:04.931Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}