AwsScheduleExpressionValidator 1.2.0

dotnet add package AwsScheduleExpressionValidator --version 1.2.0
                    
NuGet\Install-Package AwsScheduleExpressionValidator -Version 1.2.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="AwsScheduleExpressionValidator" Version="1.2.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="AwsScheduleExpressionValidator" Version="1.2.0" />
                    
Directory.Packages.props
<PackageReference Include="AwsScheduleExpressionValidator" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add AwsScheduleExpressionValidator --version 1.2.0
                    
#r "nuget: AwsScheduleExpressionValidator, 1.2.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package AwsScheduleExpressionValidator@1.2.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=AwsScheduleExpressionValidator&version=1.2.0
                    
Install as a Cake Addin
#tool nuget:?package=AwsScheduleExpressionValidator&version=1.2.0
                    
Install as a Cake Tool

aws-schedule-expression-validator

Validate AWS EventBridge Scheduler expressions (cron, rate, and at) and optionally enforce minimum/maximum intervals between runs. Includes FluentValidation integrations.

Features

  • Validate cron(...), rate(...), and at(...) expressions
  • Accepts bare CRON fields for backward compatibility
  • Validate interval constraints (min/max) between occurrences
  • Retrieve upcoming execution times
  • FluentValidation rule extensions

Installation

dotnet add package AwsScheduleExpressionValidator

Usage

Fluent validation API

using AwsScheduleExpressionValidator;

var result = "rate(5 minutes)"
    .ValidateAwsScheduleExpression()
    .WithMinInterval(TimeSpan.FromMinutes(1))
    .WithMaxInterval(TimeSpan.FromMinutes(10))
    .Evaluate();

var isValid = "cron(0 10 * * ? *)"
    .ValidateAwsScheduleExpression()
    .IsValid();

var occurrences = "rate(1 minutes)"
    .ValidateAwsScheduleExpression()
    .WithOccurrenceCount(3)
    .WithOccurrenceStart(DateTimeOffset.UtcNow)
    .GetNextScheduleExpressionOccurrences();

"invalid"
    .ValidateAwsScheduleExpression()
    .ThrowExceptionOnFailure()
    .Evaluate();
Fluent API reference
  • ValidateAwsScheduleExpression()
    • Starts validation for a schedule expression string.
  • WithMinInterval(TimeSpan)
    • Sets a minimum interval constraint.
  • WithMaxInterval(TimeSpan)
    • Sets a maximum interval constraint.
  • WithOccurrenceCount(int)
    • Sets the number of occurrences to return for GetNextScheduleExpressionOccurrences().
  • WithOccurrenceStart(DateTimeOffset)
    • Sets the starting point for occurrence calculation.
  • ThrowExceptionOnFailure()
    • Throws AwsScheduleExpressionFormatException, AwsScheduleIntervalConfigurationException, or AwsScheduleIntervalViolationException when validation fails.
  • IsValid()
    • Returns true/false for the current configuration.
  • Evaluate()
    • Returns AwsScheduleExpressionValidationResult with IsValid, Error, and Message.
  • GetNextScheduleExpressionOccurrences()
    • Returns upcoming execution times using the configured occurrence settings.

Format validation

using AwsScheduleExpressionValidator;

// Valid CRON expression
var isValid = AwsScheduleExpressionValidator.ValidateFormat("cron(0 10 * * ? *)");
var isValid = AwsScheduleExpressionValidator.ValidateFormat("0 10 * * ? *");

// Valid rate expression
var isValid = AwsScheduleExpressionValidator.ValidateFormat("rate(5 minutes)");

// Valid at expression
var isValid = AwsScheduleExpressionValidator.ValidateFormat("at(2024-12-31T23:59:00)");

Validate with interval constraints

using AwsScheduleExpressionValidator;

var minInterval = TimeSpan.FromHours(1);
var maxInterval = TimeSpan.FromDays(1);

var isValid = AwsScheduleExpressionValidator.ValidateWithIntervals("rate(5 minutes)", minInterval, maxInterval);

Get upcoming executions

using AwsScheduleExpressionValidator;

var nextRuns = AwsScheduleExpressionValidator.GetNextOccurrences("cron(0 10 * * ? *)", count: 5);

foreach (var run in nextRuns)
{
    Console.WriteLine(run.ToLocalTime().ToString("f"));
}

FluentValidation integration

using AwsScheduleExpressionValidator;
using FluentValidation;

public class ScheduleRequest
{
    public string Expression { get; set; } = string.Empty;
}

public class ScheduleRequestValidator : AbstractValidator<ScheduleRequest>
{
    public ScheduleRequestValidator()
    {
        // Basic format validation
        RuleFor(x => x.Expression)
            .MustBeValidAwsSchedule();

        // Validate with a minimum interval of 5 minutes
        RuleFor(x => x.Expression)
            .MustBeValidAwsSchedule(TimeSpan.FromMinutes(5));
            
        // Validate with a maximum interval of 24 hours
        RuleFor(x => x.Expression)
            .MustBeValidAwsSchedule(null, TimeSpan.FromHours(24));
            
        // Validate with a minimum interval of 5 minutes and a maximum interval of 24 hours
        RuleFor(x => x.Expression)
            .MustBeValidAwsSchedule(TimeSpan.FromMinutes(5), TimeSpan.FromHours(24));
    }
}

Notes

  • For at(...) expressions, interval constraints are not applicable (one-time schedules).
  • When no cron(...) prefix is provided, the validator assumes the input is a CRON expression.
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.2.0 142 3/1/2026
1.1.0 108 2/25/2026
1.0.0 104 2/25/2026