Islamic dress-code is necessary in Iran. However, these rules are not observed very strictly, especially for tourists and foreigners.
https://www.letsgoiran.com/iran-women-dress-code/