Metadata-Version: 2.1
Name: aws-cron-expression-validator
Version: 1.0.10
Summary: ValidatesAWS EventBridge cron expressions, which are similar to, but not compatible with Unix style cron expressions
Author-email: Graham Coster <bitjugglers@gmail.com>
Project-URL: Homepage, https://github.com/grumBit/aws_cron_expression_validator.git
Project-URL: Bug Tracker, https://github.com/grumBit/aws_cron_expression_validator/issues
Project-URL: Source, https://github.com/grumBit/aws_cron_expression_validator
Project-URL: Security Policy, https://github.com/grumbit/aws_cron_expression_validator/blob/master/SECURITY.md
Classifier: Development Status :: 5 - Production/Stable
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.7
Description-Content-Type: text/markdown
License-File: LICENSE

![PyPI](https://img.shields.io/pypi/v/aws_cron_expression_validator)
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/aws_cron_expression_validator)
![GitHub all releases](https://img.shields.io/github/downloads/grumbit/aws_cron_expression_validator/total)
[![GitHub license](https://img.shields.io/github/license/grumbit/aws_cron_expression_validator)](https://github.com/grumbit/aws_cron_expression_validator/blob/master/LICENSE)
![PyPI - Implementation](https://img.shields.io/pypi/implementation/aws_cron_expression_validator)
![PyPI - Wheel](https://img.shields.io/pypi/wheel/aws_cron_expression_validator)
![PyPI - Status](https://img.shields.io/pypi/status/aws_cron_expression_validator)
[![GitHub issues](https://img.shields.io/github/issues/grumbit/aws_cron_expression_validator)](https://github.com/grumbit/aws_cron_expression_validator/issues)
[![GitHub forks](https://img.shields.io/github/forks/grumbit/aws_cron_expression_validator)](https://github.com/grumbit/aws_cron_expression_validator/network)
[![GitHub stars](https://img.shields.io/github/stars/grumbit/aws_cron_expression_validator)](https://github.com/grumbit/aws_cron_expression_validator/stargazers)

# AWSCronExpressionValidator

Validates these [AWS EventBridge cron expressions](https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-create-rule-schedule.html#eb-cron-expressions), which are similar to, but not compatible with Unix style cron expressions;

| Field        | Values          | Wildcards     |
| :----------: | :-------------: | :-----------: |
| Minute       | 0-59            | , - * /       |
| Hour         | 0-23            | , - * /       |
| Day-of-month | 1-31            | , - * ? / L W |
| Month        | 1-12 or JAN-DEC | , - * /       |
| Day-of-week  |  1-7 or SUN-SAT | , - * ? L #   |
| Year         | 1970-2199       | , - * /       |

This was inspired by Niloy Chakraborty's [AWSCronValidator.py](https://gist.github.com/ultrasonex/e1fdb8354408a56df91aa4902d17aa6a) project.

# Installing

To install the library run;

```bash
pip install aws-cron-expression-validator
```

# Usage

```python
from aws_cron_expression_validator.validator import AWSCronExpressionValidator, AWSCronExpressionMinuteError

my_expression = "0 180 ? * MON-FRI *"
try:
    AWSCronExpressionValidator.validate(my_expression)
except AWSCronExpressionMinuteError:
    print(f"Oh no! My expression has an invalid minute field: {e}")
except ValueError as e:
    print(f"Oh no! My expression was invalid: {e}")
```
