PC01-L02 · guided challenge

Delivery eligibility

Combine customer status, country, and a minimum order value.

Practical CEL4 test casesDocumented
What will I practise?

You can translate an allow-list and an inclusive numeric threshold into a readable condition.

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

Delivery is available only to an active, unblocked customer in an allowed country whose order reaches the configured minimum total.

Exact requirements

  1. The customer is active.
  2. The customer is not blocked.
  3. The country occurs in allowedCountries.
  4. The order total is at least minimumTotal.

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: Test the country with in; the threshold includes the exact minimum value.

Tip: press Ctrl/⌘ + Enter to run all tests.
All conditions passNot run yet
Expected: true · bool
Show JSON input
{
  "customer": {
    "active": true,
    "blocked": false,
    "country": "SK"
  },
  "order": {
    "total": 75
  },
  "allowedCountries": [
    "SK",
    "CZ"
  ],
  "minimumTotal": 50
}
Blocked customerNot run yet
Expected: false · bool
Show JSON input
{
  "customer": {
    "active": true,
    "blocked": true,
    "country": "SK"
  },
  "order": {
    "total": 75
  },
  "allowedCountries": [
    "SK",
    "CZ"
  ],
  "minimumTotal": 50
}
Disallowed countryNot run yet
Expected: false · bool
Show JSON input
{
  "customer": {
    "active": true,
    "blocked": false,
    "country": "AT"
  },
  "order": {
    "total": 75
  },
  "allowedCountries": [
    "SK",
    "CZ"
  ],
  "minimumTotal": 50
}
Exact minimum valueNot run yet
Expected: true · bool
Show JSON input
{
  "customer": {
    "active": true,
    "blocked": false,
    "country": "CZ"
  },
  "order": {
    "total": 50
  },
  "allowedCountries": [
    "SK",
    "CZ"
  ],
  "minimumTotal": 50
}
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
customer.active && !customer.blocked && customer.country in allowedCountries && order.total >= minimumTotal

Why the solution works

  1. The first two conditions decide whether the customer account can continue.
  2. in compares the country with the configured list.
  3. >= includes an order exactly at the minimum.
  4. All four requirements are mandatory, so they are joined with &&.

What the test cases prove

  • All conditions pass: expected true (bool).
  • Blocked customer: expected false (bool).
  • Disallowed country: expected false (bool).
  • Exact minimum value: 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 translate an allow-list and an inclusive numeric threshold into a readable condition.

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.