mirror of
https://github.com/nasa/openmct.git
synced 2025-06-14 13:18:15 +00:00
Address decorability of role validation
This commit is contained in:
@ -34,10 +34,13 @@ services which can be applied to domain objects.
|
|||||||
|
|
||||||
[RegistrationOptions |
|
[RegistrationOptions |
|
||||||
+ priority : number or string
|
+ priority : number or string
|
||||||
|
]<:-[RoleOptions |
|
||||||
|
+ validate : function (DomainObject) : boolean
|
||||||
]
|
]
|
||||||
|
|
||||||
[Role.<T> |
|
[Role.<T> |
|
||||||
+ validate(domainObject : DomainObject) : boolean
|
+ validate(domainObject : DomainObject) : boolean
|
||||||
|
+ decorate(decoratorFn : function (T, V) : T, options? : RoleOptions)
|
||||||
]-:>[Factory.<T, DomainObject>]
|
]-:>[Factory.<T, DomainObject>]
|
||||||
[Factory.<T, DomainObject>]-:>[Factory.<T, V>]
|
[Factory.<T, DomainObject>]-:>[Factory.<T, V>]
|
||||||
```
|
```
|
||||||
@ -90,6 +93,10 @@ mct.roles.persistenceRole.decorate(function (persistence, domainObject) {
|
|||||||
return domainObject.getModel().type === 'someType' ?
|
return domainObject.getModel().type === 'someType' ?
|
||||||
new DifferentPersistence(domainObject) :
|
new DifferentPersistence(domainObject) :
|
||||||
persistence;
|
persistence;
|
||||||
|
}, {
|
||||||
|
validate: function (domainObject, next) {
|
||||||
|
return domainObject.getModel().type === 'someType' || next();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user