private boolean hasValidLength() {
		long limit = Memory.MAX_BLOCK_SIZE;
		long spaceLimit = startAddr.getAddressSpace().getMaxAddress().subtract(startAddr);
		if (spaceLimit >= 0) {
			limit = Math.min(limit, spaceLimit + 1);
		}
		if (length > 0 && length <= limit) {
			return true;
		}
		message = "Please enter a valid Length: 1 to 0x" + Long.toHexString(limit);
		return false;
	}
Model to manage adding a memory block.
Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/memory/AddBlockModel.java