Digital PCT265 defect: Missing moecule.id to moduleName validation for the replacement behavior.
This commit is contained in:
parent
6c841c078a
commit
472323f303
@ -49,9 +49,15 @@ public class ReplaceableMoleculeBehavior: PageMoleculeTransformationBehavior, Pa
|
||||
public func onPageNew(rootMolecules: [MoleculeModelProtocol], _ delegateObject: MVMCoreUIDelegateObject?, changes: inout [MoleculeModelProtocol]) -> [MoleculeModelProtocol]? {
|
||||
self.delegateObject = delegateObject
|
||||
|
||||
let moleculeModels = moleculeIds.compactMap { moleculeId in
|
||||
let moleculeModels: [MoleculeModelProtocol] = moleculeIds.compactMap { moleculeId in
|
||||
do {
|
||||
return try delegateObject?.moleculeDelegate?.getModuleWithName(moleculeId)
|
||||
guard let molecule = try delegateObject?.moleculeDelegate?.getModuleWithName(moleculeId) else {
|
||||
return nil // Valid. Module might not be present yet.
|
||||
}
|
||||
guard molecule.id == moleculeId else {
|
||||
throw MolecularError.validationError("The module name \(moleculeId) must match the molecule id \(molecule.id) it encloses!")
|
||||
}
|
||||
return molecule
|
||||
} catch {
|
||||
let coreError = MVMCoreErrorObject.createErrorObject(for: error, location: String(describing: type(of: self)))!
|
||||
if let error = error as? HumanReadableDecodingErrorProtocol {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user