#validation #expression #reso #expression-parser #rets #rcp19

no-std rets_expression

Implementation of RETS Validation Expressions from RESO RCP19

6 releases

new 0.2.3 Nov 11, 2024
0.2.2 Nov 11, 2024
0.2.1 Sep 22, 2024
0.1.1 Jul 20, 2023

#260 in Testing

Download history 1369/week @ 2024-07-28 560/week @ 2024-08-04 860/week @ 2024-08-11 608/week @ 2024-08-18 754/week @ 2024-08-25 619/week @ 2024-09-01 801/week @ 2024-09-08 557/week @ 2024-09-15 813/week @ 2024-09-22 724/week @ 2024-09-29 706/week @ 2024-10-06 574/week @ 2024-10-13 454/week @ 2024-10-20 448/week @ 2024-10-27 280/week @ 2024-11-03 2135/week @ 2024-11-10

3,318 downloads per month

MIT license

125KB
3K SLoC

An implementation of RCP 19 (RETS Validation Expressions) from the RESO Transport group.

See the docs for usage.

This repo tests against the compliance tests at https://github.com/zenlist/reso-rcp19-compliance-tests


lib.rs:

An implementation of RCP 19 (RETS Validation Expressions) from the RESO Transport group.

Example

use rets_expression::{Expression, Engine, EvaluateContext};
use serde_json::json;

// Parse an expression
let expression = "MlsStatus .IN. ('Active', 'Pending') .AND. (ListPrice >= 1 .OR. LAST MlsStatus = 'Incomplete')"
    .parse::<Expression>()
    .unwrap();

// Create the property data to run the expression against
let value = json!({
    "MlsStatus": "Active",
    "ListPrice": 1000000
});
// Create the previous property data to run the expression against (for when the expression
// includes references to previous data, like `LAST FieldName`)
let previous_value = json!({
    "MlsStatus": "Incomplete",
    "ListPrice": 0
});

// Create a default engine and a context in which to evaluate the expression
let engine = Engine::default();
let context = EvaluateContext::new(&engine, &value).with_previous(&previous_value);

// Evaluate the expression!
let value = expression.apply(context).unwrap();
assert_eq!(value.into_owned(), json!(true));

Dependencies

~4–9.5MB
~96K SLoC