Debian Codegraph @

doc/antora/modules/unlang/pages/case.adoc

raw
1 = The case Statement
2
3 .Syntax
4 [source,unlang]
5 ----
6 case [ <match> ] {
7 [ statements ]
8 }
9 ----
10
11 The `case` statement is used to match data inside of a
12 xref:switch.adoc[switch] statement. The `case` statement cannot be used
13 outside of a xref:switch.adoc[switch] statement.
14
15
16 The `<match>` text can be an attribute reference such as `&User-Name`,
17 or it can be a xref:type/index.adoc[string]. If the match
18 text is a dynamically expanded string, then the match is performed on
19 the output of the string expansion.
20
21 If no `<match>` text is given, it means that the `case` statement is
22 the "default" and will match all which is not matched by another
23 `case` statement inside of the same xref:switch.adoc[switch].
24
25 .Example
26 [source,unlang]
27 ----
28 switch &User-Name {
29 case "bob" {
30 reject
31 }
32
33 case &Filter-Id {
34 reject
35 }
36
37 case {
38 ok
39 }
40 }
41 ----
42
43 // Copyright (C) 2020 Network RADIUS SAS. Licenced under CC-by-NC 4.0.
44 // Development of this documentation was sponsored by Network RADIUS SAS.