Different number of classes in training and validation data

Error when checking model target: expected dense_8
I get the error above when I run the following code:

It seems to me that since the validation data contains not all the classes present in the training data, something breaks. Is it necessary that the validation data must contain data for all classes in the training data?

Thanks a lot for the help!