Closed tommiii closed 6 years ago
Did defined schemas? Are the names right? Could you supply a repository for test case?
Schemas are defined with the same name of the commands. For the repository I could but it will take time.
Could you post the output of domain.getInfo();
after initilization ?
{ contexts:
[
{ name: 'tracking',
aggregates: [
{ name: 'tracking',
version: 0,
commands: [
{ name: 'track',
version: 0,
preConditions: [
{ name: 'track',
description: 'User is authenticated',
priority: Infinity
}
],
preLoadConditions: []
}
],
events: [
{ name: 'tracked', version: 0
}
],
businessRules: [
{ name: 'aggregateValidationRule',
description: 'Aggregate validation schema',
priority: Infinity
},
{ name: 'eventValidationRule',
description: 'Event validation schema',
priority: Infinity
}
]
}
]
}
]
}
and after run something like that :
const cmd = domain.tree.getContext('tracking').aggregates[0].commands[0]; // tracking.tracking.track
console.log(!!cmd.validator);
Is the result true or false ? If it is false the problem is somewhere in your definitions ( are the schemas in .json files ? )
Problem found. Seems a namespace issue. We organised the folders structure in this way:
So the library sees the .js file but no the .json . Is there a way for fix it without changing the structure?
Hello @adrai,
about this issue would be possible to extend the loader to correctly use the json files?
Apparently, they are rightly loaded (if they contain a wrong json I do get errors) but they are not actually used to validated the commands.
I think that the loader gets partially confused because they are not in the main directory.
is this still an issue? Can’t reproduce it.
Still an issue yep, will try to reproduce in a repo tomorrow and then will share
Sent from BlueMail
On 25 Jul 2018, 21:03, at 21:03, Adriano Raiano notifications@github.com wrote:
is this still an issue? Can’t reproduce it.
-- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/adrai/node-cqrs-domain/issues/124#issuecomment-407860603
Here you could find a test case: https://github.com/alemhnan/test-repo
I tried to move the json schema in various location but nothing worked. I suspect the actual error to be quite silly but I can't find anything wrong.
Hey @alemhnan , the issue in your test-repo is that you don't have a "title" property inside you json schema. Because of the way the current structure loader works (https://github.com/adrai/node-cqrs-domain/blob/master/lib/structure/structureLoader.js#L16-L18), you must have a matching title property. Adding it results in a validation error when running your test-repo.
Hope it helps =]
Just tested, you're right. Problem solved, thanks. 🥇
I've noticed that the JSON schema validation is not working for commands, I tried to debug the your code but I din't find no one line of code where the JSON is actually validated. Should be automatic or do I need to enable some flag?