Can you use soaps and synthetic detergents to check the hardness of water?

Hard water contains calcium and magnesium ions. Soaps get precipitated as insoluble calcium and magnesium soaps in hard water as a scum but detergents do not. Synthetic detergents produce foam in both soft and hard water. Thus, soaps can be used but synthetic detergent cannot be used to check the hardness of water.