RETS Change Proposal 37: Update Transaction Validation
Author: Mark Lesswing
Organization: National Association of REALTORS® Center for REALTOR® Technology
Telephone: (312)329-8273
Address: 430 N. Michigan, Chicago, IL 60611
Email: mlesswing@realtors.org
Status: Proposal
Date: 07/24/2003
Proposal Version: 1.0
1. Synopsis
Replace the current validation mechanism with an ECMA endorsed standard language (JavaScript) for performing validation on either the client or server.
2. Rationale
European Computer Manufacturers Association (ECMA) has endorsed JavaScript as a standard language. For many years, the language has been refined due to its support in most popular browsers. Because of its heritage, the knowledge base of developers is also plentiful. JavaScript supports many desirable features in a programming language including built-in functions, ÒobjectÓ encapsulation, array processing and logic constructs. There are even may self-help and reference materials published on the language. Parsers and runtime environments are also readily available for most combinations of operating systems and programming languages.

Using a standard language with robust features and support will make RETS easier to operate (lowering the learning curve), make performance more predictable between vendors (third party support for the language) and cheaper to develop (developers have to write/maintain less code). There are ECMAScript interpreters available in Java and C++, as well as ECMAScript interpretation capabilities in Microsoft Windows.

3. Proposal
3.1. Specification Changes

Extend the METADATA-UPDATE_TYPE structure to include a reference (URL) to a body of code, written in JavaScript (ECMA). Including a URL is optional. The RETS GET Transaction can be used to retrieve the code for client-side validation. The retrieved script contains functions with well-defined signatures that can be called during validation of an update transaction.

The METADATA_VALIDATION-EXPRESSION metadata will no longer be needed and is eliminated by this change, as are references to it.

3.2. ECMAScript Function Signatures

Each function intended to be called during the validation process shall have a well-defined signature:

function(old_fields, new_fields, environment)

where old_fields is a JavaScript associative array containing the fields from the existing record, if any; new_fields is a JavaScript associative array containing the desired new values, and environment is a JavaScript associative array containing environment information as described below.

A script loaded from the URL specified in ValidationScriptURL shall have zero or more of the following functions, to be called at the indicated time:

Function NameOperation
validate_beginCalled when an editing session operating on a particular record is about to begin, before any other functions are called for that record.
validatenameCalled when the field name has been changed by external action (that is, by the user or program, not by action of the validation script).
validate_for_submissionCalled when all modifications to the data have been completed but before sending the Update transaction.

These functions shall return an array of objects containing the following:

Element NameContent
field_nameThe name of the field found to be in error, if the error is associated with a single field.
error_numberAn error number that MAY be used in displaying error information.
error_is_fatalAn integer representing a Boolean value indicating that the error condition would preclude storing the record. An error in which this field is 0 or false MAY still allow storage on the server.
error_messageA string describing the error.
3.4. Environment information

The environment parameter to the validation function shall be a JavaScript associative array containing the values in Section 4.9 of the RETS specification, as well as several additional items:

Element NameContent
.TODAY.A value representing today's date, as defined by the application.
.NOW.A value representing the current date and time.
.USER_AGENT.A string containing the client's UserAgent identification.
.SESSION_ID.A string containing the session ID for the current session, if any.

3.5. Operation

The client software may use the script in whatever fashion is appropriate for the client's function. In an interactive client, the client MAY attempt to call a validatename function at the conclusion of editing the field with the given name, and present any error information to the user immediately upon the function's return.

In addition, the client MAY call the script's validate_for_submission at the end of the editing session, when the user indicates no further intent to change field values.

If the client intends to call any field or final validation function, it MUST call the validate_begin function, if any, before any fields have been changed. The client need not call any of the validatename functions even if it eventually calls the validate_for_submit function.

4. Development Impact
5. Compatibility
Faster to implement from either the client or server perspective. The current METADATA-UPDATE_TYPE structure is extended by one column, and the GET transaction is used to retrieve the code.
6. Proof/Need of Concept Examples
None.