Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
onChangeSegment(i, value) {
const invalid = this.state.invalid.slice();
const atoms = this.state.atoms.slice();
const field = CronExpression.map[i + 1]; // The .map also has seconds, skip over it
atoms[i] = value;
try {
CronExpression._parseField(
field,
value,
CronExpression.constraints[i + 1]);
} catch (e) {
invalid[i] = e.message;
return this.setState({ atoms, invalid });
}
const schedule = atoms.join(' ');
invalid[i] = false;
this.setState({ atoms, invalid, schedule }, () => {
if (this.props.onChange) this.props.onChange(this.getValue());
});