People with epilepsy have a greater risk of traffic accidents because they may have a seizure while driving.
That is why Spanish law bans people from driving cars when they have uncontrolled seizures. These are people who have had a seizure at some point in the last year. There may be greater restrictions for specific licences for other kinds of vehicles.
If you meet the legal requirements stipulated for each kind of licence, you may be able to obtain a driving licence with a report from your neurologist or epileptologist supporting your application.
In any case, you are always recommended to report your diagnosis before obtaining a licence because if you have an accident your insurance policy may not cover you if you have failed to provide relevant details. Also, if you change medication or treatment you are recommended to avoid driving until it is confirmed that your seizures are under control.
The specific Spanish legal regulation concerning this is point 8 of Orden PRE/2356/2010, de 3 de septiembre, por la que se modifica el Anexo IV del Reglamento General de Conductores, aprobado por el Real Decreto 818/2009, de 8 de mayo.