RULESCRIPT / REFERENCE

Readable rules.
A preserved foundation.

The historical RuleGenius language for data validation and transformation, reorganized into a practical reference.

What is RuleScript?

RuleScript is the original domain-specific language proposed for expressing data transformations and validations in readable text. Its core idea separates the declaration of a rule from the environment that executes it.

The examples use quoted field names, explicit operation keywords and optional error messages. They are useful as a language reference; edge cases and actual support require a defined runtime.

Syntax & examples

1. Transform a record

transform.rs
rename "price_usd" to "price";
split "full_name" into "first_name", "last_name" by " ";
map "country_code" [US: "United States", CA: "Canada", MX: "Mexico"];

2. Validate values

validate.rs
validate "price": number, min 0, max 10000, on error "Price must be valid";
validate "country": required, in ["United States", "Canada", "Mexico"], on error "Invalid country";

3. Combine explicit steps

Apply the intended rename and mapping before checking the resulting field values. Preserve the original data and make the transformation order explicit.

combined.rs
rename "price_usd" to "price";
validate "price": number, min 0, max 10000, on error "Price must be valid";

4. Conditional validation

conditional.rs
validate "discount": number, on error "Discount must be numeric", if "price" > 100;

The historical example omitted its final semicolon; it is normalized here. The order of optional clauses and the behavior of missing fields remain runtime specification questions.

21 entries shown

Transformations

1. Rename Field

Change the name of a column in your dataset. For example, rename "price_usd" to "price" :

transformation.rs
rename "price_usd" to "price";

Parameters: field, new name

2. Split Field

Split the content of a column into multiple new columns based on a delimiter. For instance, splitting "full_name" into "first_name" and "last_name" :

transformation.rs
split "full_name" into "first_name", "last_name" by " ";

Parameters: field, target fields, delimiter

3. Merge Fields

Combine the content of multiple columns into one. For example, merging "first_name" and "last_name" into "full_name" with a space separator:

transformation.rs
merge "first_name", "last_name" into "full_name" with " ";

Parameters: source fields, target field, separator

4. Map Values

Replace values in a column based on a predefined mapping. For example, mapping "US" to "United States" :

transformation.rs
map "country_code" [US: "United States", CA: "Canada", MX: "Mexico"];

Parameters: field, mapping

5. Convert Data Type

Change a column’s data type, such as converting a string to an integer. For example:

transformation.rs
convert "quantity" to integer;

Parameters: field, target type

6. Calculate New Field

Create a new column based on a formula or logic. For example, calculating a "total" field:

transformation.rs
calculate "total" as "price * quantity";

Parameters: new field, expression

7. Normalize Case

Standardize text to lowercase, uppercase, or title case. For instance, converting all text in "name" to lowercase:

transformation.rs
normalize "name" to lowercase;

Parameters: field, case mode

8. Replace Values

Replace specific values in a column. For example, replacing NULL with "N/A" :

transformation.rs
replace "status" null with "N/A";

Parameters: field, old value, replacement

9. Round Numbers

Round numeric values to a specific number of decimal places. For example, rounding "price" to two decimal places:

transformation.rs
round "price" to 2 decimal places;

Parameters: field, decimal places

10. Anonymize Data

Historical field masking example. This does not establish irreversible anonymization or guarantee privacy.

transformation.rs
anonymize "email" with "****@domain.com";

Parameters: field, mask

11. Drop Columns

Remove unnecessary columns from the dataset. For example, dropping "temp_field" :

transformation.rs
drop "temp_field";

Parameters: field(s)

12. Impute Missing Values

Fill missing values in a column with a default, mean, or median value. For example, replacing missing values in "age" with the average:

transformation.rs
impute "age" missing with average;

Parameters: field, imputation method

13. Reorder Columns

Change the order of columns in the dataset. For example, reordering columns to "id", "name", "email" :

transformation.rs
reorder columns "id", "name", "email";

Parameters: ordered field list

14. Filter Rows

Remove rows that do not meet specific conditions. For example, keeping only rows where "age" is greater than 18:

transformation.rs
filter "age" > 18;

Parameters: condition

Validation functions

1. Required

Ensure a column is not empty or null. For example, ensuring "name" is always present:

validation.rs
validate "name": required, on error "Name is required";

Parameters: field; optional on error

2. Data Type Validation

Check that a column matches the expected data type (e.g., number , integer , string , date , time , datetime ):

validation.rs
validate "age": number, on error "Age must be numeric";

Parameters: field, data type; optional on error

3. Range Validation

Ensure numeric values fall within a range (min and max). For example:

validation.rs
validate "price": number, min 0, max 10000, on error "Price must be valid";

Parameters: field, min, max; optional on error

4. In List

Ensure a column’s value is part of a predefined list. For example:

validation.rs
validate "country": in ["United States", "Canada", "Mexico"], on error "Invalid country";

Parameters: field, list; optional on error

5. Greater Than (>), Greater or Equal (>=)

Ensure values are above a specific threshold. For example:

validation.rs
validate "discount": > 0, on error "Discount must be positive";
validate "price": >= 0, on error "Price must be non-negative";

Parameters: field, threshold; optional on error

6. Less Than (<), Less or Equal (<=)

Ensure values are below a specific threshold. For example:

validation.rs
validate "age": < 18, on error "Age must be below 18";
validate "discount": <= 50, on error "Discount must be 50% or less";

Parameters: field, threshold; optional on error

7. Equal and Not Equal

Ensure values match or don’t match specific conditions. For example:

validation.rs
validate "status": equal "Active", on error "Status must be active";
validate "status": not in ["Inactive", "Suspended"], on error "Invalid status";

Parameters: field, value or excluded list; optional on error

Historical workflows

CLI

The original design used .rs source files and .rsx compiled artifacts. These are historical command shapes; no installer is provided.

historical CLI
rg-compile rules.rs
rg-run rules.rsx input.csv output.csv

API

The documentation proposed CSV batches and single JSON records. The routes below are historical sketches, not working endpoints. Multipart uploads must carry an actual file part, not the JSON filename placeholder shown on the former site.

CSV payload

historical HTTP sketch
POST /api/v1/validate/my_rules.rsx
Content-Type: multipart/form-data; boundary=example

--example
Content-Disposition: form-data; name="file"; filename="input.csv"
Content-Type: text/csv

price,country
25,US
--example--

Single JSON record

historical HTTP sketch
POST /api/v1/validate/my_rules.rsx
Content-Type: application/json

{"record":{"full_name":"Sample Person","price":-50,"country_code":"US"}}
illustrative response
{"status":"error","errors":[{"field":"price","error":"Price must be between 0 and 10000"}]}

Batch processing checks a complete delivery; record validation checks an event or submission. A future implementation must specify error handling and consistency across both interfaces.

Pipelines

historical pipeline
rg-transform step1.rsx input.csv \
  | rg-transform step2.rsx \
  | rg-validate rules.rsx --output output.csv

This preserves the original pipeline concept. A runtime would need a defined stream format and exit-code behavior before this can be used reliably.

Private deployment

On-premises execution was a deployment direction on the old site. It is not an available enterprise offering announced here, and does not by itself establish compliance with any regulation.

Try two checks in your browser.

This small browser demonstration checks a numeric price from 0 to 10000 and a country code from US, CA or MX. It is hand-written JavaScript for these two checks, not a RuleScript parser or the future engine. Your input stays in this page.

0 ≤ price ≤ 10000 · country ∈ {US, CA, MX}

Run the checks to see a result.

What changes in the migration?

  • RuleScript remains the language name. The .rs and .rsx examples are preserved as documentation; changing the website does not change their execution semantics.
  • Curly quotes are normalized for copying. The conditional example now includes a closing semicolon.
  • The 14 transformations and 7 validation groups are preserved. CLI and API sketches are labeled with their status.
  • Masking is described accurately; it is not presented as a guarantee of anonymization.

Interested in the project? Let’s talk.