Since I don't know the way a level is implemented in your game, I will give a general answer.
Typically, the game has a set of known rules (constraints) by which it operates. You need to apply them in your validation algorithm.
My solution for a (I assume) complex game like yours would be, as follows.
After the level has been generated, run a simulation. If the simulation solved the puzzle, you're done. Otherwise, fix the existing level or generate a new one and start over.
A simple example of this can be seen here, where he first generates a world according to a few simple rules (making corridors), places his agents on map and runs simulation to validate the level. If simulation fails, he tries to fix the level. If simulation is still failing, he generates a whole new world and starts over.
Alternatively, you could avoid the expensive game simulation by using a search algorithm like the A* algorithm, which can serve as a puzzle solver directly on your data structures.
Another option might be evolutionary algorithms, although they can be quite computationally expensive and cannot guarantee valid levels.
EDIT: As DMGregory noted in the comments, you're better off generating a valid level as you go, rather than fixing it after it's been generated. This will most probably produce better levels and will be computationally cheaper. However, the implementation is naturally harder, especially when you're after complex level generation.