sebthom/oval

Could OValContext preserve _args, _returns and _this?

Closed this issue · 3 comments

cnfn commented

If constraint violations occur in @Pre and @Post check, it will throw a ConstraintsViolatedException exception. But ConstraintViolation.invalidValue is always null(validateMethodPre, validateMethodPost). Then, we will never to know the invalid value is what.

We cannot to know who trigger the violation by a easy way, because the expression maybe include _this, _args, or returns. So we cannot to preverse the invalidValue.

But, if we preserve all the value like _this, _args, returns by ConstraintViolation.context, it should be help developers find and fix bugs.

Do you think so?

_this is already accessible via ConstraintViolation.getValidatedObject().

I don't think exposing the return value in case of a constraint violation is a good idea because that defeats the whole purpose of preventing the computed return value being accessible when a validation error is detected.

cnfn commented

I'm new to DBC, could you explain why cannot access the return value? Thanks~

Besides _this and _returns, how about _args and _old?

stale commented

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions.