PC05-L03 · independent challenge

All events before a deadline

Combine a non-empty list with a time predicate for every event.

Practical CEL4 test casesDocumented
What will I practise?

You can put time conversion inside all() and define the meaning of an empty collection deliberately.

How is it checked?

Your one expression must produce the expected result for all four JSON inputs.

When am I done?

When all tests pass and you can explain every condition in your expression.

Word problem

The event list is valid only when it is non-empty and every event occurs at or before one common deadline.

Exact requirements

  1. Reject the empty list explicitly.
  2. Parse each event time inside the macro.
  3. Allow an event exactly at the deadline.
  4. Reject the list when any event is late.

Required result

Write one CEL expression. It must return the expected value and type for all four prepared JSON inputs. Do not change the inputs to make an incomplete expression pass.

Recommended procedure

  1. Translate each numbered requirement into one small boolean condition.
  2. Run the starter expression and inspect which cases fail.
  3. Add one condition at a time and run the complete suite again.
  4. Mark the challenge complete only when you can explain every operator and every boundary.

Solve the challenge · browser test suite

Write one expression that passes every case

Edit the CEL expression, then run it against all prepared JSON inputs. A solution is complete only when every case passes.

4 test cases

Hint: all() alone is true for an empty list, but this task requires at least one event.

Tip: press Ctrl/⌘ + Enter to run all tests.
All on timeNot run yet
Expected: true · bool
Show JSON input
{
  "events": [
    {
      "at": "2026-07-23T09:00:00Z"
    },
    {
      "at": "2026-07-23T10:00:00Z"
    }
  ],
  "deadline": "2026-07-23T10:00:00Z"
}
One late eventNot run yet
Expected: false · bool
Show JSON input
{
  "events": [
    {
      "at": "2026-07-23T09:00:00Z"
    },
    {
      "at": "2026-07-23T10:00:01Z"
    }
  ],
  "deadline": "2026-07-23T10:00:00Z"
}
Empty listNot run yet
Expected: false · bool
Show JSON input
{
  "events": [],
  "deadline": "2026-07-23T10:00:00Z"
}
One exactly at deadlineNot run yet
Expected: true · bool
Show JSON input
{
  "events": [
    {
      "at": "2026-07-23T10:00:00Z"
    }
  ],
  "deadline": "2026-07-23T10:00:00Z"
}
Test result

Not run yet

The same expression runs against every case. Test data is fixed so that boundary and failure scenarios cannot be skipped.

Explained solution

Show the complete expression
events.size() > 0 && events.all(event, timestamp(event.at) <= timestamp(deadline))

Why the solution works

  1. size() > 0 overrides the vacuous true result of all() on an empty list.
  2. all() binds one event at a time.
  3. Both sides of each comparison are timestamps.
  4. One false predicate makes the complete all() result false.

What the test cases prove

  • All on time: expected true (bool).
  • One late event: expected false (bool).
  • Empty list: expected false (bool).
  • One exactly at deadline: expected true (bool).

The cases are intentionally different. A solution that passes only the first case has not yet implemented the complete rule.

Common mistake

Do not optimise the expression for the first successful input. A requirement is implemented only when its positive case, negative case, and boundary case all produce the stated result.

Knowledge check

Can you point to the exact part of the solution that makes each false test case fail? If two different failures depend on the same condition, explain why.

Key takeaway

You can put time conversion inside all() and define the meaning of an empty collection deliberately.

Sources

  • CEL-DEV — official CEL overview.
  • CEL-LANG — official CEL language definition for operators, types, macros, presence, strings, and time values used in this challenge.