A bathroom isn’t an ideal place for a washing machine. For a start, if the bathroom is upstairs and the washing machine flooded it could cause a lot of damage to the ceiling in the room below. A bathroom tends to be steamy and potentially damp. That is never good for electronics. However, it is OK to have a washing machine installed in a bathroom, as long as strict rules are adhered to.
These rules are covered under your local authority regulations and need to be followed exactly. The main criteria is that a person in the bath or shower (and presumably even on the toilet) should NOT be able to touch the washing machine. The washing machine should also be plugged in outside the bathroom and protected by an RCD.
If you must install a washing machine in a bathroom, seek out and consult the official regulations. I can’t guarantee there have not been any changes to the regulations since writing this article. Your local council will have them. Here's a site you can use to find your local council authority