When transitioning between chapters in a saga, there's a concept of ChapterValidation. Given a successful validation, the transitions completes, otherwise it fails:
public SomeChapter : Chapter, ICanTranstionTo<AnotherChapter> {...}
public class SomeChapterValidator : ChapterValidator<SomeChapter> {...}
sagaNarrator.TransitionTo<AnotherChapter>(saga); //success or fail based on SomeChapterValidator
This falls through a bit, when implementing flow between chapters, where different validation applies to different transitions. In the following example, if SecondChapter isn't valid, it cant transition back to FirstChapter
Example:
public SecondChapter : Chapter, ICanTranstionTo<FirstChapter>, ICanTransitionTo<LastChapter> {...}
public class SecondChapterValidator : ChapterValidator<SecondChapter> {...}
sagaNarrator.TransitionTo<FirstChapter>(saga); //fails, even though we might not want validation when going back to first step
Given that Chapters build up a state machine, it leads me to believe that transitions should be able to validate differently. Meaning that different transitions should have it's own validators. Or rather be specific when a specific transition needs validation. Something on the lines of:
public class SecondChapterValidator : ChapterValidatorBetween<SecondChapter,LastChapter> {...} //complex rules
public class SecondChapterValidator : ChapterValidatorBetween<SecondChapter,FirstChapter> {...} //no rules, or just non existent
Given CurrentChapter is SecondChapter:
sagaNarrator.TransitionTo<LastChapter>(saga); // fails if is unvalid
sagaNarrator.TransitionTo<FirstChapter>(saga); // fails if is unvalid
Thoughts?