Hemi JavaScript Framework

Hemi.data.validator

Description

The Data Validator service applies patterns defined by Data Validator Definitions, and may be used for Virtual Forms from the Data Form service to validate against field values whose nodes may or may not exist.

Class Index

static Hemi.data.validator.service

version 3.1.0

Static instance of XHTMLValidatorImpl.

Hemi.data.validator.serviceImpl

version 3.1.0

A service for managing asynchronous and dependency-driven actions.

See Example Implementation for an example of implementating the script on a page.

Index

Example Index

Property Index

Method Index

Examples

Example Implementation

This is an example of using the validator service to validate a form field.

Example Code

<input type = "text" id = "oText" value = "my@ email.com" />
<script type = "text/javascript">
   var oT = document.getElementById("oText");
   // validate oText against the "email-address pattern
   var bValid = Hemi.data.validator.service.validateField(oT,"email-address");
   // obtain the error text for the "email-address" pattern.
   var sE = Hemi.data.validator.service.getValidationErrorText("email-address");
}
</script>

Properties

object_config

Object API structure for storing sub structures: object_config.pointers and object_config.status.

Syntax

object = object.object_config

object_id

Unique instance identifier.

Syntax

String = object.object_id

object_type

The type of this object.

Syntax

String = object.object_type

object_version

Version of the object class.

Syntax

String = object.object_version

ready_state

Object load and execution state. Follows: 0 unitialized, 1 through 3 variant, 4 ready, 5 destroyed.

Syntax

int = object.ready_state

Methods

getIsWebSafe

Returns true if the field value validates against the web-safe pattern.

Syntax

b = getIsWebSafe( o )

Parameters

Returns

b as boolean: Bit indicating whether the specified field value validated against the

getObjectId

Returns the unique id of the object.

Syntax

i = getObjectId( )

Returns

i as String: The unique object instance id.

getObjectType

Returns the type of the object.

Syntax

t = getObjectType( )

Returns

t as String: The type of the object instance.

getObjectVersion

Returns the version of the object.

Syntax

v = getObjectVersion( )

Returns

v as String: The version of the object instance.

getPointers

Returns the object_config.pointers sub structure.

Syntax

o = getPointers( )

Returns

o as object: The object_config.pointers substructure.

getReadyState

Returns the state of the object.

Syntax

s = getReadyState( )

Returns

s as int: The object ready state.

getStatus

Returns the object_config.status sub structure.

Syntax

o = getStatus( )

Returns

o as object: The object_config.status substructure.

getValidationErrorText

Returns the validation error text for the specified pattern id or based on the specified DOM Node.

Syntax

s = getValidationErrorText( o )

Parameters

Returns

s as String: Validation error text.

validateField

Returns true if the field value validates against the specified pattern, and returns true if no pattern is specified; otherwise returns false.

Syntax

b = validateField( o, i )

Parameters

Returns

b as boolean: Bit indicating whether the specified field value validated against the specified pattern.