Validate required and extra object fields
Rejecting unknown fields and enforcing required fields are independent policy choices. Return both diagnostics in one pass through the workflow. The example both omits required field 2 and supplies unrecognized field 9. The report retains both counts.
Run the framework with your own input
Install Blyx 0.2.1 and a Rust toolchain with a host linker, then run the versioned project. Each positional argument is a number or a comma-separated numerical vector. The CLI accepts up to 16 entries per vector. The imported module accepts longer inputs.
git clone --depth 1 --branch v0.1.0 https://github.com/Rahulchaube1/blyx-bulbul.git
cd blyx-bulbul
blyxc native-run project.blyx -- "1,9" "1,2" "1,2" 1API and return values
Returns [accepted, missing count, extra count, first missing ID]. Use an explicit field-name-to-ID map. Closed mode rejects extra fields; required IDs must be in the declared allowed set. Invalid input returns an empty vector.
| Argument | Accepted input |
|---|---|
| present | Vector of: nonnegative exact integer |
| allowed | Vector of: nonnegative exact integer |
| required | Vector of: nonnegative exact integer |
| closed | nonnegative exact integer |
Use the libraries independently
The framework vendors the same library source published in these two repositories. Each module has its own package page, input contract and regression suite.
Try the program
Expected output
0 1 1 2
Practice
Change allowed = [1], required = [1], closed = 0.0. Predict the result, then run the program.
Hint
Returns [accepted, missing count, extra count, first missing ID]. Use an explicit field-name-to-ID map. Closed mode rejects extra fields; required IDs must be in the declared allowed set.
Worked solution
The result vector is [1, 0, 1, -1]. Compare its fields with the return layout in the API section.
Find
let allowed = [1, 2];Replace with
let allowed = [1];Find
let required = [1, 2];Replace with
let required = [1];Find
let closed = 1.0;Replace with
let closed = 0.0;Output after the change
1 0 1 -1
