She committed zina before her wedding and got pregnant, then had a miscarriage. Is her marriage valid?
Question

                I had an affair with a guy a week to my wedding with a different
person.Some months later I discovered that Im pregnant for the
first guy not my husband.I had a miscarriage and later became pregant
for my husband.Uptil now nobody knew about this,at times i feel like confessing but he esitat .

My question here is please how valid is my marriage
and how does this affect my child islamically?.
Praise be to Allah.Firstly: 
If this immoral action came 
    after the marriage contract was done, even if it was before the wedding 
    party, then this marriage of yours is valid but you have to repent from this 
    sin that you fell into. 
Ibn Qudaamah (may Allah 
    have mercy on him) said: 
If the wife of a man 
    commits zina, or her husband commits zina, the marriage contract is not 
    rendered invalid, whether that happens before or after consummation, 
    according to the opinion of most of the scholars.
End quote from al-Mughni, 
    9/565 
Secondly: 
If this zina took place 
    before the marriage contract was done, the marriage contract is not valid 
    unless it was done after establishing that there was no pregnancy by waiting 
    for one menstrual cycle, according to the more correct opinion. 
Shaykh al-Islam Ibn 
    Taymiyah (may Allah have mercy on him) said: 
Marriage to a zaaniyah (a 
    woman who has committed fornication) is haraam until she repents, whether 
    the one who committed zina with her is the bridegroom himself or someone 
    else. This is the correct opinion beyond a doubt, and it is the opinion of a 
    number of the earlier and later scholars, including Ahmad ibn Hanbal and 
    others. Many of the earlier and later scholars were of the view that it is 
    permissible, and this is the view of the three, but Maalik stipulated that 
    it should be established that there is no pregnancy by waiting for one 
    menstrual cycle, and Abu Haneefah regarded it as permissible to do the 
    marriage contract before waiting for one menstrual cycle if she is pregnant, 
    however if she is pregnant it is not permissible to have intercourse with 
    her until she gives birth. Ash-Shaafa‘i regarded it as permissible to do the 
    marriage contract and to have intercourse in all cases, because the water 
    (semen) of the zaani has no value in sharee‘ah and the ruling is that no 
    child is to be attributed to him. This is his justification for his opinion. 
    Abu Haneefah differentiated between the one who is pregnant and the one who 
    is not, because if (the husband) has intercourse with the one who is 
    pregnant, he will be attributing to himself a child who definitely is not 
    his, which is different from the case of one who is not pregnant. Maalik and 
    Ahmad stipulated that it should be established that there is no pregnancy 
    (by waiting for one menstrual cycle), which is the correct view. But Maalik 
    and Ahmad, according to another report, stipulated that it should be 
    established that there is no pregnancy by waiting for one menstrual cycle. 
    The other report from Ahmad is that which is followed by many of his 
    companions such as al-Qaadi Abu Ya‘la and his followers, which is that it is 
    essential to wait for three menstrual cycles. However the correct view is 
    that all that is required is to establish that there is no pregnancy (by 
    waiting for one menstrual cycle). End quote. 
Majmoo‘ al-Fataawa, 
    32/110 
Shaykh Ibn ‘Uthaymeen (may 
    Allah have mercy on him) said in ash-Sharh al-Mumti‘ (13/382): Rather 
    the opinion narrated from Abu Bakr and a number of the Sahaabah (may Allah 
    be pleased with them) is that there is no ‘iddah at all for the woman who 
    committed zina, and there is no requirement to establish that there is no 
    pregnancy, especially if she has a husband, because of the words of the 
    Messenger (blessings and peace of Allah be upon him): “The infant is to be 
    attributed to the husband of the woman (who gave birth to him).” Rather if a 
    man knows that his wife has committed zina – Allah forbid – and has 
    repented, he should have intercourse with her immediately, so that no doubt 
    will remain in his heart in the future as to whether she became pregnant as 
    a result of zina or not. If he has intercourse with her immediately, the 
    child will be assumed to be from the husband and not from the zaani 
    (adulterer). 
But if the woman who 
    committed zina (fornication) did not have a husband, it is essential to 
    establish that there is no pregnancy by waiting for one menstrual cycle, 
    according to the correct opinion. End quote. 
Thirdly: 
Because this issue is the 
    subject of a considerable difference of opinion among the scholars, and 
    because annulling the marriage and admitting zina after this length of time 
    will lead to a great deal of trouble and disclosing that which Allah had 
    concealed for you, and will expose you to turmoil, we think – and Allah 
    knows best – that in this case you do not have to tell your husband about 
    what happened in order to renew the marriage contract. In the other 
    scholarly opinion mentioned above, according to which some of the scholars 
    are of the opinion that it is not essential to establish that there is no 
    pregnancy, there is some leeway. 
This, as we have said, 
    applies if the zina took place before the marriage contract was done and 
    before it was established that there was no pregnancy. 
As Allah has concealed you, 
    you must also conceal yourself and do not breach the concealment of Allah. 
    al-Bukhaari (6069) and Muslim (2990) narrated that Abu Hurayrah (may Allah 
    be pleased with him) said: I heard the Messenger of Allah (blessings and 
    peace of Allah be upon him) say: “All of my ummah will be fine except those 
    who commit sin openly, and it is part of committing sin openly for a man to 
    do something at night, then in the morning when his Lord has concealed him 
    he says: O So and so, I did such and such last night, when his Lord had 
    concealed him all night, but in the morning he discloses that which Allaah 
    had concealed for him.” 
And Muslim (2590) narrated 
    from Abu Hurayrah (may Allah be pleased with him) that the Prophet 
    (blessings and peace of Allah be upon him) said: “Allaah does not conceal a 
    person in this world but Allaah will conceal him on the Day of 
    Resurrection.” 
Al-Bayhaqi (18056) narrated 
    from Ibn ‘Umar that the Messenger of Allah (blessings and peace of Allah be 
    upon him) said, after the stoning of al-Aslami: “Avoid this filth that Allah 
    has forbidden, and whoever falls into it, let him conceal himself with the 
    concealment of Allah, may He be glorified and exalted.”
Classed as saheeh by al-Albaani 
    in as-Saheehah (663). 
Fourthly: 
Your son is a legitimate 
    son of your husband, and there is no problem concerning him, in sha Allah. 
With regard to the foetus 
    whom you aborted, if that happened before the soul was breathed into him – 
    i.e., before four months – then there is no expiation or diyah required for 
    him. However you are required to repent, feel regret and pray for 
    forgiveness. 
If that happened after four 
    months, then you have to pay the diyah and offer expiation.
The diyah is to free a male 
    or female slave; if that is not possible then you must pay the equivalent, 
    which is five camels.
With regard to the 
    expiation, it is to free a slave. If that is not possible, then you must 
    fast for two consecutive months.
See also the answer to 
    question no. 106448
And Allah knows best.