automata/cron/validator

Types

pub type Item {
  Exact(Int)
  Range(Int, Int)
  Step(StepBase, Int)
}

Constructors

  • Exact(Int)
  • Range(Int, Int)
  • Step(StepBase, Int)
pub type Selector {
  Any
  Values(List(Item))
}

Constructors

  • Any
  • Values(List(Item))
pub type StepBase {
  StepAny
  StepExact(Int)
  StepRange(Int, Int)
}

Constructors

  • StepAny
  • StepExact(Int)
  • StepRange(Int, Int)

A cron expression that has passed validate/1. opaque so the only way to obtain a value is through validation, preventing callers from forging “validated” inputs.

pub opaque type ValidCron
pub type ValidationError {
  UnsupportedSyntax(field: ast.Field, value: String)
  InvalidNumber(field: ast.Field, value: String)
  InvalidAlias(field: ast.Field, value: String)
  InvalidRange(field: ast.Field, value: String)
  InvalidStep(field: ast.Field, value: String)
  InvalidList(field: ast.Field, value: String)
  OutOfRange(field: ast.Field, min: Int, max: Int, actual: Int)
  ImpossibleDate(day_of_month: String, month: String)
}

Constructors

  • UnsupportedSyntax(field: ast.Field, value: String)
  • InvalidNumber(field: ast.Field, value: String)
  • InvalidAlias(field: ast.Field, value: String)
  • InvalidRange(field: ast.Field, value: String)
  • InvalidStep(field: ast.Field, value: String)
  • InvalidList(field: ast.Field, value: String)
  • OutOfRange(field: ast.Field, min: Int, max: Int, actual: Int)
  • ImpossibleDate(day_of_month: String, month: String)

Values

pub fn day_of_month(spec: ValidCron) -> Selector
pub fn day_of_week(spec: ValidCron) -> Selector
pub fn hour(spec: ValidCron) -> Selector
pub fn minute(spec: ValidCron) -> Selector
pub fn month(spec: ValidCron) -> Selector
pub fn selector_values(
  selector: Selector,
  min: Int,
  max: Int,
  normalize_day_of_week normalize_day_of_week: Bool,
) -> List(Int)
pub fn to_string(spec: ValidCron) -> String
pub fn validate(
  raw raw: ast.RawCron,
) -> Result(ValidCron, ValidationError)
Search Document