def num_val_batches(self) -> list[Union[int, float]]:
        """The number of validation batches that will be used during ``trainer.fit()`` or ``trainer.validate()``."""
        if self.state.fn == TrainerFn.VALIDATING:
            return self.validate_loop.max_batches
        # if no trainer.fn is set, assume fit's validation
        # use the protected access, because it shouldn't return the sanity_val batches
        return self.fit_loop.epoch_loop.val_loop._max_batches
The number of validation batches that will be used during ``trainer.fit()`` or ``trainer.validate()``.
src/lightning/pytorch/trainer/trainer.py