Soby Web Components

Presence Validator

This example demonstrates how to use presence validator in the Soby Validator.
"sobyValidate.GetValidator" method takes one parameter. The parameter is the type of the validator. This method returns the validator for the given type. "Validate" method of the validator, returns as invalid if the given value is null, undefined or empty string. It returns as valid if the given value is not null, undefined or empty string.

 sobyValidate.GetValidator(soby_ValidatorTypes.Presence).Validate(null);
Output:false
sobyValidate.GetValidator(soby_ValidatorTypes.Presence)Validate(undefined);
Output:false
sobyValidate.GetValidator(soby_ValidatorTypes.Presence).Validate("");
Output:false
sobyValidate.GetValidator(soby_ValidatorTypes.Presence).Validate("test");
Output:true
sobyValidate.GetValidator(soby_ValidatorTypes.Presence).Validate("32");
Output:true
sobyValidate.GetValidator(soby_ValidatorTypes.Presence).Validate("! */+");
Output:true

View source