1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
//! TOML configuration validation for Harmony Proxy.
//!
//! This module provides validation functionality for TOML configuration files
//! using the Harmony DSL schema definitions.
//!
//! # Examples
//!
//! ## Validating a config.toml file
//!
//! ```no_run
//! use runbeam_sdk::validation::validate_config_toml;
//!
//! let content = std::fs::read_to_string("config.toml").unwrap();
//! match validate_config_toml(&content) {
//! Ok(()) => println!("Configuration is valid!"),
//! Err(e) => eprintln!("Validation failed: {}", e),
//! }
//! ```
//!
//! ## Validating a pipeline.toml file
//!
//! ```no_run
//! use runbeam_sdk::validation::validate_pipeline_toml;
//!
//! let content = std::fs::read_to_string("pipelines/http.toml").unwrap();
//! match validate_pipeline_toml(&content) {
//! Ok(()) => println!("Pipeline configuration is valid!"),
//! Err(e) => eprintln!("Validation failed: {}", e),
//! }
//! ```
//!
//! ## Validating with a custom schema
//!
//! ```no_run
//! use runbeam_sdk::validation::validate_toml;
//!
//! let schema = r#"
//! [schema]
//! version = "1.0"
//! description = "Custom schema"
//!
//! [[table]]
//! name = "app"
//! required = true
//!
//! [[table.field]]
//! name = "name"
//! type = "string"
//! required = true
//! "#;
//!
//! let content = r#"
//! [app]
//! name = "my-app"
//! "#;
//!
//! validate_toml(content, schema).unwrap();
//! ```
pub use ValidationError;
pub use ;
use ;
/// Validate a Harmony Proxy config.toml file.
///
/// This function validates the content against the CONFIG_SCHEMA from harmony-dsl,
/// which defines the structure for main gateway configuration files.
///
/// # Example
///
/// ```no_run
/// use runbeam_sdk::validation::validate_config_toml;
///
/// let content = r#"
/// [proxy]
/// id = "gateway-1"
///
/// [network.default]
/// bind_address = "0.0.0.0"
/// port = 8080
/// "#;
///
/// validate_config_toml(content).unwrap();
/// ```
///
/// # Errors
///
/// Returns a `ValidationError` if the configuration is invalid. The error will
/// contain detailed information about what validation rule failed and where.
/// Validate a Harmony Proxy pipeline.toml file.
///
/// This function validates the content against the PIPELINE_SCHEMA from harmony-dsl,
/// which defines the structure for pipeline configuration files.
///
/// # Example
///
/// ```no_run
/// use runbeam_sdk::validation::validate_pipeline_toml;
///
/// let content = r#"
/// [pipelines.http_api]
/// networks = ["default"]
/// endpoints = ["http_endpoint"]
/// backends = ["api_backend"]
///
/// [endpoints.http_endpoint]
/// service = "http"
///
/// [backends.api_backend]
/// service = "http"
/// "#;
///
/// validate_pipeline_toml(content).unwrap();
/// ```
///
/// # Errors
///
/// Returns a `ValidationError` if the pipeline configuration is invalid.
/// Validate TOML content against a custom schema.
///
/// This is a generic validation function that allows you to validate any TOML
/// content against any schema written in the Harmony DSL format.
///
/// # Example
///
/// ```
/// use runbeam_sdk::validation::validate_toml;
///
/// let schema = r#"
/// [schema]
/// version = "1.0"
/// description = "Application config"
///
/// [[table]]
/// name = "app"
/// required = true
///
/// [[table.field]]
/// name = "name"
/// type = "string"
/// required = true
///
/// [[table.field]]
/// name = "port"
/// type = "integer"
/// required = true
/// min = 1
/// max = 65535
/// "#;
///
/// let content = r#"
/// [app]
/// name = "my-application"
/// port = 8080
/// "#;
///
/// assert!(validate_toml(content, schema).is_ok());
/// ```
///
/// # Errors
///
/// Returns a `ValidationError` if:
/// - The schema TOML is invalid
/// - The content TOML is invalid
/// - The content doesn't match the schema validation rules