refactor run changes to build error object
This commit is contained in:
parent
4a76e08fad
commit
efae25583c
1 changed files with 9 additions and 3 deletions
|
@ -19,9 +19,15 @@ const PhonoChangeApplier = () => {
|
|||
const runChanges = e => {
|
||||
e.preventDefault();
|
||||
// validate rules
|
||||
console.log(epochs.forEach(epoch => {
|
||||
if (epoch.changes.find(change => !change.match(/>.*\/.*_/))) console.log({error: 'improper rule formatting'});
|
||||
}))
|
||||
let error = epochs.reduce((errorObject, epoch) => {
|
||||
epoch.changes.map((change, index) => {
|
||||
if (!change.match(/>.*\/.*_/)) errorObject[epoch.name]
|
||||
? errorObject[epoch.name].push(index)
|
||||
: errorObject[epoch.name] = [index]
|
||||
})
|
||||
return errorObject;
|
||||
}, {})
|
||||
console.log(error)
|
||||
// validate lexicon
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue