diff --git a/src/PhonoChangeApplier.js b/src/PhonoChangeApplier.js index a4fdd76..8d52d83 100644 --- a/src/PhonoChangeApplier.js +++ b/src/PhonoChangeApplier.js @@ -15,11 +15,12 @@ const PhonoChangeApplier = () => { const [ epochs, setEpochs ] = useState([{name: 'epoch 1', changes:['[+ feature]>[- feature]/_#']}]); const [ options, setOptions ] = useState({output: 'default', save: false}) const [ results, setResults ] = useState([]) + const [ errors, setErrors ] = useState({}) const runChanges = e => { e.preventDefault(); - // validate rules - let error = epochs.reduce((errorObject, epoch) => { + + let ruleError = epochs.reduce((errorObject, epoch) => { epoch.changes.map((change, index) => { if (!change.match(/>.*\/.*_/)) errorObject[epoch.name] ? errorObject[epoch.name].push(index) @@ -27,16 +28,18 @@ const PhonoChangeApplier = () => { }) return errorObject; }, {}) - console.log(error) - // validate lexicon + if (Object.entries(ruleError).length) return setErrors(ruleError) + setErrors({}); + + // setResults } return (
{`Formatting errors in line(s) ${props.error.join(', ')}`}
+ : <>>}