Zeinab Donati, Zeinab Donati has been studying books about various Islamic subjects for more than 19 years. She is deeply interested in history and politics as well as social issues in particular those pertaining... Answered 1 year ago

Assalamu aleykum,
Thanks for your question.
If the son is illegitimate he has no right to inherit, so yes, the will is completely valid.
Please refer at the texts here below.

*****
- The Illegitimate Child (Walad al-Zina)
The lmamiyyah say: There is no mutual inheritance between an illegitimate child and its fornicator mother, in the same manner as there is no such inheritance between the child and its fornicator father, because there is a common impeding cause between the two, i.e. fornication.
https://www.al-islam.org/inheritance-according-five-schools-islamic-law-...

*****
- Views of Imamye scholars concerning inheritance of the illegitimate child
1. Most Imamye scholars assume lack of inheritance between the illegitimate child and his natural parents. In this regard Sheikh Toosi states:" child of adultery does not have lineage and does not inherit from the adulterer and the one who bore him and his heritage reaches his children and in case children do not exist, the property [inheritance] belongs to the Imam. Contemporary scholars assume lack of inheritance between the child of adultery and his parents (Khoee, 1996:414). Thus, what causes inheritance is relation and lineage where relation is connection of somebody with another by means of the latter whether relation is led to him or not (Imami 1993)
http://www.worldscientificnews.com/wp-content/uploads/2015/10/WSN-44-201...

- Custody of Illegitimate Child

Jurists see that hidana and nafaqa (expenditure) of an illegitimate child must be undertaken by the child biological parents, although the child does not inherit from them. Makārim Shīrāzī, Istiftāʾāt-i Jadīd, vol. 3, p. 266.

- Imam Khomeini, Tahrirol Wasaail in English, Volume 4, Section 44: Laws on Inheritance, Fourth Impediment, birth by Fornication (Zina), page 29 onwards.