@@ -11,20 +11,26 @@ export interface ValidatorError {
1111 * alphabet. Returns `true` or a string describing the error.
1212 *@param a The automata.
1313 */
14- export function automataValidate ( a :Readonly < Automata > ) :boolean | Array < ValidatorError > {
14+ export function automataValidate ( a :Readonly < Automata > ) :true | Array < ValidatorError > {
1515const errors = new Array < ValidatorError > ( ) ;
1616
17- if ( ! ( a . starting in a . states ) ) {
17+ if ( a . starting == null ) {
1818errors . push ( {
1919path :[ "start" ] ,
20- error :`no state named "${ a . starting } " exists`
20+ error :`no starting state selected`
21+ } ) ;
22+ }
23+ else if ( ! ( a . starting in a . states ) ) {
24+ errors . push ( {
25+ path :[ "start" ] ,
26+ error :`the starting state "${ a . starting } " does not exists`
2127} ) ;
2228}
2329for ( const targetStateName of a . accepting ) {
2430if ( ! ( targetStateName in a . states ) ) {
2531errors . push ( {
2632path :[ "accepting" ] ,
27- error :`no statenamed "${ targetStateName } " exists`
33+ error :`the accepting state "${ targetStateName } " does not exists`
2834} ) ;
2935}
3036}
@@ -43,7 +49,7 @@ export function automataValidate(a: Readonly<Automata>): boolean | Array<Validat
4349 *@param g The graph.
4450 *@param a The alphabet.
4551 */
46- export function graphValidate ( g :Readonly < Graph > , a :ReadonlySet < string > ) :boolean | Array < ValidatorError > {
52+ export function graphValidate ( g :Readonly < Graph > , a :ReadonlySet < string > ) :true | Array < ValidatorError > {
4753const errors = new Array < ValidatorError > ( ) ;
4854
4955for ( const stateName in g ) {