@@ -30,28 +30,14 @@ private static class AllRules
3030 . Property ( item => item . Value )
3131 . WithRule ( ( dto , valueInDisplayUnit ) =>
3232 {
33- var valueInBaseUnit = dto . Parameter . ConvertToBaseUnit ( valueInDisplayUnit ) ;
34-
3533 // Nan values are invalid
36- if ( double . IsNaN ( valueInBaseUnit ) )
34+ if ( double . IsNaN ( valueInDisplayUnit ) )
3735 return false ;
3836
39- // evaluate without updating the parameter because writing a value will trigger another validation
40- if ( valueInBaseUnit == dto . Parameter . Value )
41- return effectiveMolWeightIsValid ( dto ) ;
42-
43- // Update the parameter value to evaluate if the effective mol weight will be valid.
44- // Reset to the old value after
45- var oldValue = dto . Parameter . Value ;
46- try
47- {
48- dto . Parameter . Value = valueInBaseUnit ;
49- return effectiveMolWeightIsValid ( dto ) ;
50- }
51- finally
52- {
53- dto . Parameter . Value = oldValue ;
54- }
37+ // For effective mol weight is a formula-only calculation and is updated through halogens and/or mol weight
38+ // and never directly from user input. The value at time of validation is always current because the triggering
39+ // update has already occurred. Either mol weight was updated, or halogen count
40+ return effectiveMolWeightIsValid ( dto ) ;
5541 } )
5642 . WithError ( ( dto , value ) =>
5743 PKSimConstants . Error . EffectiveMolWeightMustBeGreaterThan (
0 commit comments