Density functional theory powers our understanding of matter at the quantum level. Its tremendous success hinges on accurate modelling of the exchange-correlation functional, but all popular approximations violate mathematical conditions of the exact functional, leading to pervasive errors. We overcome these fundamental failures by training a deep neural network on molecular data and exact conditions for fractional charge and spin. The resulting functional, DM21, accurately describes the archetypal challenges of artificial charge delocalization and strong correlation, and is state-of-the-art on stringent bench-marks. These unique capabilities allow us to describe interesting electronic structure, from compressed hydrogen chains to DNA base pairs and diradical transition states. Our approach demonstrates the success of a data- and constraint-driven path towards the exact universal functional.