#expression #validation #serde-json #rets #reso #rcp19

no-std rets_expression

Implementation of RETS Validation Expressions from RESO RCP19

2 releases

0.1.1 Jul 20, 2023
0.1.0 Jul 14, 2023

#895 in Encoding

Download history 1820/week @ 2023-12-13 1114/week @ 2023-12-20 1195/week @ 2023-12-27 875/week @ 2024-01-03 729/week @ 2024-01-10 829/week @ 2024-01-17 884/week @ 2024-01-24 750/week @ 2024-01-31 1036/week @ 2024-02-07 1242/week @ 2024-02-14 1072/week @ 2024-02-21 1481/week @ 2024-02-28 527/week @ 2024-03-06 935/week @ 2024-03-13 1119/week @ 2024-03-20 763/week @ 2024-03-27

3,588 downloads per month

MIT license

110KB
2.5K SLoC

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

See the docs for usage.

See the compliance tests in the compliance-tests folder.


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

~2.2–9.5MB
~60K SLoC