How to use the cron-parser/lib/expression.constraints function in cron-parser

To help you get started, we’ve selected a few cron-parser examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github auth0 / webtask-widget / src / components / editor / cronEditor.js View on Github external
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());
        });
    }
}

cron-parser

Node.js library for parsing crontab instructions

MIT
Latest version published 9 months ago

Package Health Score

77 / 100
Full package analysis