You can use oclIsInvalid() in OCL expressions to test whether an expression evaluates to the special value invalid.
Syntax
expression.oclIsInvalid()
The operation returns a Boolean value:
Result of expression
|
expression.oclIsInvalid()
|
|---|---|
invalid
|
true
|
Any value other than invalid, including null
|
false
|
Use oclIsInvalid to distinguish invalid from null
In OCL, invalid and null are different results. Use oclIsInvalid() when you specifically need to detect an invalid evaluation result.
For example, the following expression evaluates to true only when SomeExpression is invalid:
SomeExpression.oclIsInvalid()
If you need to treat both invalid and null as undefined, use oclIsUndefined() instead:
SomeExpression.oclIsUndefined()
Example
Use oclIsInvalid() when an expression must identify an invalid result without classifying a missing value as invalid.
self.Name.oclIsInvalid()
This expression returns true when evaluating self.Name produces invalid. If self.Name is null, it returns false.
Use in MDriven
MDriven uses OCL for model constraints, derived values, and ViewModel definitions, including column visibility and enable expressions. OCL is a query language: expressions must not change data. Use oclIsInvalid() as a Boolean test within such expressions when the distinction between invalid and null affects the rule.
