jhy/jsoup · error · ValidationException
Must be false
Error message
Must be false
What it means
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.
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
Example fix
// before
Validate.isFalse(doc.getElementsByTag("script").isEmpty() == false); // scripts present
// after
if (doc.getElementsByTag("script").isEmpty()) { process(doc); }
else { sanitize(doc); } Defensive patterns
Strategy: validation
Validate before calling
if (forbiddenCondition) {
// remediate: deduplicate, sanitize, or reject before the guarded call
return;
} Try / catch
try {
guardedOperation();
} catch (ValidationException e) {
if (e.getMessage().equals("Must be false")) {
log.warn("Forbidden state detected; skipping");
} else { throw e; }
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- Must be true
- msg (String.format with args)
- Pattern syntax error:
- Pattern complexity error
- Pattern syntax error:
AI-assisted analysis of jhy/jsoup@9851ac5d9c (2026-09-08).
Data as JSON: /api/errors/7e5ae5bdf136db91.
Report an issue: GitHub.
Appendix: source
Thrown at src/main/java/org/jsoup/helper/Validate.java:103
/**
* Validates that the value is true
* @param val object to test
* @param msg message to include in the Exception if validation fails
* @throws ValidationException if the object is not true
*/
public static void isTrue(boolean val, String msg) {
if (!val)
throw new ValidationException(msg);
}
/**
* Validates that the value is false
* @param val object to test
* @throws ValidationException if the object is not false
*/
public static void isFalse(boolean val) {
if (val)
throw new ValidationException("Must be false");
}
/**
* Validates that the value is false
* @param val object to test
* @param msg message to include in the Exception if validation fails
* @throws ValidationException if the object is not false
*/
public static void isFalse(boolean val, String msg) {
if (val)
throw new ValidationException(msg);
}
/**
* Validates that the array contains no null elements
* @param objects the array to test
* @throws ValidationException if the array contains a null element
*/View on GitHub (pinned to 9851ac5d9c)