Jel. Validator

A collection of validation routines (also used by Jel.FormValidator)

Summary
A collection of validation routines (also used by Jel.FormValidator)
checks if a string value is not an empty string
checks if the length of a string value is greater than or equal to a specific value
checks if the length of a string value is greater than a specific value
checks if the length of a string value is less than or equal to a specific value
checks if the length of a string value is less than a specific value
checks if the length of a string is equal to a specific value
checks if the length of a string is not equal to a specific value
checks if the length of a string is between a lower and upper bound (inclusive by default, but can be overridden)
checks if a string value represents a positive or negative integer
checks if a string value represents a positive integer
checks if a string value represents a negative integer
checks if a string value represents a positive or negative float
checks if a string value represents a positive float
checks if a string value represents a negative float
checks if a string value represents a positive or negative float or integer
checks if a string value represents a positive float or integer
checks if a string value represents a negative float or integer
checks if a string value represents a date in a specified format.
checks if a string value represents a valid email address
checks if a string value falls within a given range, assuming a specific type (and format if the type is a date)
checks if a string value falls within a given range, assuming a specific type (and format if the type is a date), and is case insensitive if type is string
checks if a string value is equal to another, assuming a specific type (and format if the type is a date)
checks if a string value is equal to another, assuming a specific type (and format if the type is a date), and is case insensitive if type is string
checks if a string value is not equal to another, assuming a specific type (and format if the type is a date)
checks if a string value is not equal to another, assuming a specific type (and format if the type is a date), and is case insensitive if type is string
checks if a string value is greater than another, assuming a specific type (and format if the type is a date)
checks if a string value is greater than another, assuming a specific type (and format if the type is a date), and is case insensitive if type is string
checks if a string value is less than another, assuming a specific type (and format if the type is a date).
checks if a string value is less than another, assuming a specific type (and format if the type is a date), and is case insensitive if type is string
checks if a string value is greater than or equal to another, assuming a specific type (and format if the type is a date)
checks if a string value is greater than or equal to another, assuming a specific type (and format if the type is a date), and is case insensitive if type is string
checks if a string value is less than or equal to another, assuming a specific type (and format if the type is a date)
checks if a string value is less than or equal to another, assuming a specific type (and format if the type is a date), and is case insensitive if type is string
checks if a string value is equal to another, comparing both as integers
checks if a string value is not equal to another, comparing both as integers
checks if a string value is less than another, comparing both as integers
checks if a string value is greater than another, comparing both as integers
checks if a string value is less than or equal to another, comparing both as integers
checks if a string value is greater than or equal to another, comparing both as integers
checks if a string value falls within a given range, comparing as integers
checks if a string value is equal to another, comparing both as floats
checks if a string value is not equal to another, comparing both as floats
checks if a string value is less than another, comparing both as floats
checks if a string value is greater than another, comparing both as floats
checks if a string value is less than or equal to another, comparing both as floats
checks if a string value is greater than or equal to another, comparing both as floats
checks if a string value falls within a given range, comparing as floats
checks if a string value is equal to another, comparing both as numeric (float or integer)
checks if a string value is not equal to another, comparing both as numeric (float or integer)
checks if a string value is less than another, comparing both as numeric (float or integer)
checks if a string value is greater than another, comparing both as numeric (float or integer)
checks if a string value is less than or equal to another, comparing both as numeric (float or integer)
checks if a string value is greater than or equal to another, comparing both as numeric (float or integer)
checks if a string value falls within a given range, comparing as numeric (float or integer)
checks if a string value is equal to another, comparing both as dates
checks if a string value is not equal to another, comparing both as dates
checks if a string value is less than another, comparing both as dates
checks if a string value is greater than another, comparing both as dates
checks if a string value is less than or equal to another, comparing both as dates
checks if a string value is greater than or equal to another, comparing both as dates
checks if a string value falls within a given range, comparing as dates
checks if a string value when converted to a date is in the future.
checks if a string value when converted to a date is in the past.

length-checking

required

required: function(value)

checks if a string value is not an empty string

Arguments

valuestring, the string to check

Returns

trueif condition is met
falseotherwise

Example

Jel.Validator.required("");           // false
Jel.Validator.required("something"); // true

lengthGe

lengthGe: function(value,
info)

checks if the length of a string value is greater than or equal to a specific value

Arguments

valuestring, the string to check
infoobject, required, an object hash that must contain an integer compare property to check against

Returns

trueif condition is met
falseotherwise

Example

Jel.Validator.lengthGe("word", { compare: 4 } ); // true
Jel.Validator.lengthGe("word", { compare: 3 } ); // true
Jel.Validator.lengthGe("word", { compare: 6 } ); // false

See Also

lengthGt

lengthGt

lengthGt: function(value,
info)

checks if the length of a string value is greater than a specific value

Arguments

valuestring, the string to check
infoobject, required, an object hash that must contain an integer compare property to check against

Returns

trueif condition is met
falseotherwise

Example

Jel.Validator.lengthGt("word", { compare: 4 } ); // false
Jel.Validator.lengthGt("word", { compare: 3 } ); // true

lengthLe

lengthLe: function(value,
info)

checks if the length of a string value is less than or equal to a specific value

Arguments

valuestring, the string to check
infoobject, required, an object hash that must contain an integer compare property to check against

Returns

trueif condition is met
falseotherwise

Example

Jel.Validator.lengthLe("word", { compare: 4 } ); // true
Jel.Validator.lengthLe("word", { compare: 5 } ); // false

lengthLt

lengthLt: function(value,
info)

checks if the length of a string value is less than a specific value

Arguments

valuestring, the string to check
infoobject, required, an object hash that must contain an integer compare property to check against

Returns

trueif condition is met
falseotherwise

Example

Jel.Validator.lengthLt("word", { compare: 5 } ); // true
Jel.Validator.lengthLt("word", { compare: 4 } ); // false

lengthEq

lengthEq: function(value,
info)

checks if the length of a string is equal to a specific value

Arguments

valuestring, the string to check
infoobject, required, an object hash that must contain an integer compare property to check against

Returns

trueif condition is met
falseotherwise

Example

Jel.Validator.lengthEq("word", { compare: 4 } ); // true
Jel.Validator.lengthEq("word", { compare: 3 } ); // false

lengthNeq

lengthNeq: function(value,
info)

checks if the length of a string is not equal to a specific value

Arguments

valuestring, the string to check
infoobject, required, an object hash that must contain an integer compare property to check against

Returns

trueif condition is met
falseotherwise

Example

Jel.Validator.lengthNeq("word", { compare: 4 } ); // false
Jel.Validator.lengthNeq("word", { compare: 3 } ); // true

lengthRange

lengthRange: function(value,
info)

checks if the length of a string is between a lower and upper bound (inclusive by default, but can be overridden)

Arguments

valuestring, the string to check
infoobject, required, am object hash (see below):

Info Hash Properties

lowerinteger, the lower bound of the length range
upperinteger, the upper bound of the length range
inclusiveboolean, whether the range is inclusive of the lower and upper bounds

Returns

trueif condition is met
falseotherwise

Example

Jel.Validator.lengthRange("word", { lower: 2, upper: 5, inclusive: false } );     // true
Jel.Validator.lengthRange("word", { lower: 2, upper: 4, inclusive: false } ); // false
Jel.Validator.lengthRange("word", { lower: 2, upper: 4, inclusive: true } ); // true
Jel.Validator.lengthRange("wo", { lower: 3, upper: 8, inclusive: false } ); // false

type-checking

intType

intType: function(value)

checks if a string value represents a positive or negative integer

Arguments

valuestring, the string to check

Returns

{ value: integer }an object hash containing the integer value of the string, if condition is met
falseotherwise

Example

Jel.Validator.int("4");       // { value: 4 }
Jel.Validator.int("word"); // false

See Also

intPositive, intNegative

intPositive

intPositive: function(value)

checks if a string value represents a positive integer

Arguments

valuestring, the string to c heck

Returns

{ value: integer }an object hash containing the integer value of the string, if condition is met
falseotherwise

Example

Jel.Validator.int_positive("4");  // { value: 4 }
Jel.Validator.int_positive("-4"); // false

See Also

<int>, intNegative

intNegative

intNegative: function(value)

checks if a string value represents a negative integer

Arguments

valuestring, the string to check

Returns

{ value: integer }an object hash containing the integer value of the string, if condition is met
falseotherwise

Example

Jel.Validator.intNegative("4");   // false
Jel.Validator.intNegative("-4"); // { value: -4 }

See Also

<int>, intPositive

floatType

floatType: function(value)

checks if a string value represents a positive or negative float

Arguments

valuestring, the string to check

Returns

{ value: float }an object hash containing the float value of the string, if condition is met
falseotherwise

Example

Jel.Validator.float("4.5");       // { value: 4.5 }
Jel.Validator.float("word"); // false
Jel.Validator.float("4"); // false

See Also

floatPositive, floatNegative

floatPositive

floatPositive: function(value)

checks if a string value represents a positive float

Arguments

valuestring, the string to check

Returns

{ value: float }an object hash containing the float value of the string, if condition is met
falseotherwise

Example

Jel.Validator.floatPositive("4.5");   // { value: 4.5 }
Jel.Validator.floatPositive("word"); // false
Jel.Validator.floatPositive("-4.5"); // false

See Also

<float>, floatNegative

floatNegative

floatNegative: function(value)

checks if a string value represents a negative float

Arguments

valuestring, the string to check

Returns

{ value: float }an object hash containing the float value of the string, if condition is met
falseotherwise

Example

Jel.Validator.floatNegative("4.5");   // false
Jel.Validator.floatNegative("word"); // false
Jel.Validator.floatNegative("-4.5"); // { value: -4.5 }

See Also

<float>, floatPositive

numericType

numericType: function(value)

checks if a string value represents a positive or negative float or integer

Arguments

valuestring, the string to check

Returns

{ value: float OR integer }an object hash containing the float OR integer value of the string, if condition is met
falseotherwise

Example

Jel.Validator.numericType("4.5");     // { value: 4.5 }
Jel.Validator.numericType("word"); // false
Jel.Validator.numericType("-4"); // { value: -4 }
Jel.Validator.numericType("-4.0"); // { value: -4.0 }

numericPositive

numericPositive: function(value)

checks if a string value represents a positive float or integer

Arguments

valuestring, the string to check

Returns

{ value: float OR integer }an object hash containing the float OR integer value of the string, if condition is met
falseotherwise

Example

Jel.Validator.numericPositive("4.5");     // { value: 4.5 }
Jel.Validator.numericPositive("85"); // { value: 85 }
Jel.Validator.numericPositive("word"); // false
Jel.Validator.numericPositive("-4"); // false
Jel.Validator.numericPositive("-4.0"); // false

numericNegative

numericNegative: function(value)

checks if a string value represents a negative float or integer

Arguments

valuestring, the string to check

Returns

{ value: float OR integer }an object hash containing the float OR integer value of the string, if condition is met
falseotherwise

Example

Jel.Validator.numericNegative("-4.5");    // { value: -4.5 }
Jel.Validator.numericNegative("word"); // false
Jel.Validator.numericNegative("-4"); // { value: -4 }
Jel.Validator.numericNegative("4.0"); // false

dateType

dateType: function(value,
info)

checks if a string value represents a date in a specified format.  The date must also be valid within the Gregorian calendar

Arguments

valuestring, the string to check
infoobject hash, required (see below)

Info hash Properties

formata string describing the format of the date (see <Date.prototype.format> for more details)

Example

Jel.Validator.dateType("28/03/2006", { format: "d/m/Y" } );   // { value: [date object, day=28, month=2, year=2006] }
Jel.Validator.dateType("31/02/2006", { format: "d/m/Y" } ); // false (not a real date)
Jel.Validator.dateType("cool", { format: "d/m/Y" } ); // false

Internet-related

email

email: function(value)

checks if a string value represents a valid email address

Arguments

valuestring, the string to check

Returns

{ value: string }an object hash containing the provided value, if condition is met
falseotherwise

Example

Jel.Validator.email("tom");               // false
Jel.Validator.email("tom@domain.com"); // { value: "tom@domain.com" }
Jel.Validator.email("tom@domain."); // false
Jel.Validator.email("4"); // false

Value-based

range

range: function(value,
info)

checks if a string value falls within a given range, assuming a specific type (and format if the type is a date)

Arguments

valuestring, the string to check
infoobject hash, required (see below)

Info Hash Properties

lowerthe lower bound of the range to check
upperthe upper bound of the range to check
type (optional)the data type to convert to in the comparisons (“int”, “float”, or “date”).  If not specified a string comparison is performed
format (optional)if type is a date, describes the input format (see <Date.prototype.format> for more details)
inclusive (optional)whether the comparison includes the lower and upper bounds.  Assumed to be true if not specified

Returns

objecta hash containing the native value of the string provided based on the type specified, if the comparison is true { value: [typed-value] }
falseotherwise

Example

 Jel.Validator.range("28/03/2006", { type: "date", lower: "23/02/2006", upper: "24/06/2006", format: "d/m/Y" } );
// { value: [date object, day=28, month=3, year=2006] }

Jel.Validator.range("5", { type: "int", lower: "4", upper: "8" } );
// { value: 5 }

rangeCi

rangeCi: function(value,
info)

checks if a string value falls within a given range, assuming a specific type (and format if the type is a date), and is case insensitive if type is string

Arguments

valuestring, the string to check
infoobject hash, required (see below)

Info Hash Properies

lowerthe lower bound of the range to check
upperthe upper bound of the range to check
type (optional)the data type to convert to in the comparisons (“int”, “float”, or “date”).  If not specified a string comparison is performed
format (optional)if type is a date, describes the input format (see <Date.prototype.format> for more details)
inclusive (optional)whether the comparison includes the lower and upper bounds.  Assumed to be true if not specified

Returns

objecta hash containing the native value of the string provided based on the type specified, if the comparison is true { value: [typed-value] }
falseotherwise

Example

 Jel.Validator.rangeCi("28/03/2006", { type: "date", lower: "23/02/2006", upper: "24/06/2006", format: "d/m/Y" } );
// { value: [date object, day=28, month=3, year=2006] }

Jel.Validator.rangeCi("5", { type: "int", lower: "4", upper: "8" } );
// { value: 5 }

eq

eq: function(value,
info)

checks if a string value is equal to another, assuming a specific type (and format if the type is a date)

Arguments

valuestring, the string to check
infoobject hash, required (see below)

Info hash Properties

comparethe value to compare to
type (optional)the data type to convert to in the comparisons (“int”, “float”, or “date”).  If not specified a string comparison is performed
format (optional)if type is a date, describes the input format (see <Date.prototype.format> for more details)

Returns

objecta hash containing the native value of the string provided based on the type specified, if the comparison is true { value: [typed-value] }
falseotherwise

Example

Jel.Validator.eq("5", { type: "int", compare: "5" } )   // { value: 5 }

eqCi

eqCi: function(value,
info)

checks if a string value is equal to another, assuming a specific type (and format if the type is a date), and is case insensitive if type is string

Arguments

valuestring, the string to check
infoobject hash, required (see below)

Info hash Properties

comparethe value to compare to
type (optional)the data type to convert to in the comparisons (“int”, “float”, or “date”).  If not specified a string comparison is performed
format (optional)if type is a date, describes the input format (see <Date.prototype.format> for more details)

Returns

objecta hash containing the native value of the string provided based on the type specified, if the comparison is true { value: [typed-value] }
falseotherwise

Example

Jel.Validator.eqCi("CAR", { compare: "car" } );   // { value: "car" }

neq

neq: function(value,
info)

checks if a string value is not equal to another, assuming a specific type (and format if the type is a date)

Arguments

valuestring, the string to check
infoobject hash, required (see below)

Info hash Properties

comparethe value to compare to
type (optional)the data type to convert to in the comparisons (“int”, “float”, or “date”).  If not specified a string comparison is performed
format (optional)if type is a date, describes the input format (see <Date.prototype.format> for more details)

Returns

objecta hash containing the native value of the string provided based on the type specified, if the comparison is true { value: [typed-value] }
falseotherwise

Example

Jel.Validator.neq("5", { type: "int", compare: "6" } );   // { value: 5 }

neqCi

neqCi: function(value,
info)

checks if a string value is not equal to another, assuming a specific type (and format if the type is a date), and is case insensitive if type is string

Arguments

valuestring, the string to check
infoobject hash, required (see below)

Info hash Properties

comparethe value to compare to
type (optional)the data type to convert to in the comparisons (“int”, “float”, or “date”).  If not specified a string comparison is performed
format (optional)if type is a date, describes the input format (see <Date.prototype.format> for more details)

Returns

objecta hash containing the native value of the string provided based on the type specified, if the comparison is true { value: [typed-value] }
falseotherwise

Example

Jel.Validator.neqCi("5", { type: "int", compare: "6" } );   // { value: 5 }

gt

gt: function(value,
info)

checks if a string value is greater than another, assuming a specific type (and format if the type is a date)

Arguments

valuestring, the string to check
infoobject hash, required (see below)

Info hash Properties

comparethe value to compare to
type (optional)the data type to convert to in the comparisons (“int”, “float”, or “date”).  If not specified a string comparison is performed
inclusive (optional)whether the comparison includes the comparison value.  In this case, assumed to be false if not specified
format (optional)if type is a date, describes the input format (see <Date.prototype.format> for more details)

Returns

objecta hash containing the native value of the string provided based on the type specified, if the comparison is true { value: [typed-value] }
falseotherwise

Example

Jel.Validator.gt("5", { type: "int", compare: "4" } );
// { value: 5 }

Jel.Validator.gt("5", { type: "int", compare: "5" } );
// false

Jel.Validator.gt("5", { type: "int", compare: "5", inclusive: true } );
// { value: 5 }

gtCi

gtCi: function(value,
info)

checks if a string value is greater than another, assuming a specific type (and format if the type is a date), and is case insensitive if type is string

Arguments

valuestring, the string to check
infoobject hash, required (see below)

Info hash Properties

comparethe value to compare to
type (optional)the data type to convert to in the comparisons (“int”, “float”, or “date”).  If not specified a string comparison is performed
inclusive (optional)whether the comparison includes the comparison value.  In this case, assumed to be false if not specified
format (optional)if type is a date, describes the input format (see <Date.prototype.format> for more details)

Returns

objecta hash containing the native value of the string provided based on the type specified, if the comparison is true { value: [typed-value] }
falseotherwise

Example

Jel.Validator.gtCi("5", { type: "int", compare: "4" } );
// { value: 5 }

Jel.Validator.gtCi("5", { type: "int", compare: "5" } );
// false

Jel.Validator.gtCi("5", { type: "int", compare: "5", inclusive: true } );
// { value: 5 }

lt

lt: function(value,
info)

checks if a string value is less than another, assuming a specific type (and format if the type is a date).

Arguments

valuestring, the string to check
infoobject hash, required (see below)

Info hash Properties

comparethe value to compare to
type (optional)the data type to convert to in the comparisons (“int”, “float”, or “date”).  If not specified a string comparison is performed
inclusive (optional)whether the comparison includes the comparison value.  In this case, assumed to be false if not specified
format (optional)if type is a date, describes the input format (see <Date.prototype.format> for more details)

Returns

objecta hash containing the native value of the string provided based on the type specified, if the comparison is true { value: [typed-value] }
falseotherwise

Example

Jel.Validator.lt("5", { type: "int", compare: "6" } );
// { value: 5 }

Jel.Validator.lt("6", { compare: "45" } );
// false (character comparison)

Jel.Validator.lt("5", { type: "int", compare: "5" } );
// false

Jel.Validator.lt("5", { type: "int", compare: "5", inclusive: true } );
// { value: 5 }

ltCi

ltCi: function(value,
info)

checks if a string value is less than another, assuming a specific type (and format if the type is a date), and is case insensitive if type is string

Arguments

valuestring, the string to check
infoobject hash, required (see below)

Info hash Properties

comparethe value to compare to
type (optional)the data type to convert to in the comparisons (“int”, “float”, or “date”).  If not specified a string comparison is performed
inclusive (optional)whether the comparison includes the comparison value.  In this case, assumed to be false if not specified
format (optional)if type is a date, describes the input format (see <Date.prototype.format> for more details)

Returns

objecta hash containing the native value of the string provided based on the type specified, if the comparison is true { value: [typed-value] }
falseotherwise

Example

Jel.Validator.ltCi("5", { type: "int", compare: "6" } );
// { value: 5 }

Jel.Validator.ltCi("6", { compare: "45" } );
// false (character comparison)

Jel.Validator.ltCi("5", { type: "int", compare: "5" } );
// false

Jel.Validator.ltCi("5", { type: "int", compare: "5", inclusive: true } );
// { value: 5 }

ge

ge: function(value,
info)

checks if a string value is greater than or equal to another, assuming a specific type (and format if the type is a date)

Arguments

valuestring, the string to check
infoobject hash, required (see below)

Info hash Properties

comparethe value to compare to
type (optional)the data type to convert to in the comparisons (“int”, “float”, or “date”).  If not specified a string comparison is performed
format (optional)if type is a date, describes the input format (see <Date.prototype.format> for more details)

Returns

objecta hash containing the native value of the string provided based on the type specified, if the comparison is true { value: [typed-value] }
falseotherwise

Example

Jel.Validator.ge("7", { type: "int", compare: "6" } );   // { value: 7 }
Jel.Validator.ge("5", { type: "int", compare: "5" } ); // { value: 5 }
Jel.Validator.ge("5", { type: "int", compare: "7" } ); // false

geCi

geCi: function(value,
info)

checks if a string value is greater than or equal to another, assuming a specific type (and format if the type is a date), and is case insensitive if type is string

Arguments

valuestring, the string to check
infoobject hash, required (see below)

Info hash Properties

comparethe value to compare to
type (optional)the data type to convert to in the comparisons (“int”, “float”, or “date”).  If not specified a string comparison is performed
format (optional)if type is a date, describes the input format (see <Date.prototype.format> for more details)

Returns

objecta hash containing the native value of the string provided based on the type specified, if the comparison is true { value: [typed-value] }
falseotherwise

Example

Jel.Validator.geCi("7", { type: "int", compare: "6" } );   // { value: 7 }
Jel.Validator.geCi("5", { type: "int", compare: "5" } ); // { value: 5 }
Jel.Validator.geCi("5", { type: "int", compare: "7" } ); // false

le

le: function(value,
info)

checks if a string value is less than or equal to another, assuming a specific type (and format if the type is a date)

Arguments

valuestring, the string to check
infoobject hash, required (see below)

Info hash Properties

comparethe value to compare to
type (optional)the data type to convert to in the comparisons (“int”, “float”, or “date”).  If not specified a string comparison is performed
format (optional)if type is a date, describes the input format (see <Date.prototype.format> for more details)

Returns

objecta hash containing the native value of the string provided based on the type specified, if the comparison is true { value: [typed-value] }
falseotherwise

Example

Jel.Validator.le("5", { type: "int", compare: "6" } );   // { value: 5 }
Jel.Validator.le("5", { type: "int", compare: "5" } ); // { value: 5 }
Jel.Validator.le("5", { type: "int", compare: "4" } ); // false

leCi

leCi: function(value,
info)

checks if a string value is less than or equal to another, assuming a specific type (and format if the type is a date), and is case insensitive if type is string

Arguments

valuestring, the string to check
infoobject hash, required (see below)

Info hash Properties

comparethe value to compare to
type (optional)the data type to convert to in the comparisons (“int”, “float”, or “date”).  If not specified a string comparison is performed
format (optional)if type is a date, describes the input format (see <Date.prototype.format> for more details)

Returns

objecta hash containing the native value of the string provided based on the type specified, if the comparison is true { value: [typed-value] }
falseotherwise

Example

Jel.Validator.leCi("5", { type: "int", compare: "6" } );   // { value: 5 }
Jel.Validator.leCi("5", { type: "int", compare: "5" } ); // { value: 5 }
Jel.Validator.leCi("5", { type: "int", compare: "4" } ); // false

intEq

intEq: function(value,
info)

checks if a string value is equal to another, comparing both as integers

Arguments

valuestring, the string to check
infoobject hash, required (see below)

Info hash Properties

comparethe value to compare to

Returns

objecta hash containing the integer value of the string, if the comparison is true { value: [typed-value] }, and the values are both integers
falseotherwise

Example

Jel.Validator.eq("5", { compare: "5" } );   // { value: 5 }
Jel.Validator.eq("4", { compare: "5" } ); // false

intNeq

intNeq: function(value,
info)

checks if a string value is not equal to another, comparing both as integers

Arguments

valuestring, the string to check
infoobject hash, required (see below)

Info hash Properties

comparethe value to compare to

Returns

objecta hash containing the integer value of the string, if the comparison is true { value: [typed-value] }, and the values are both integers
falseotherwise

Example

Jel.Validator.neq("5", { compare: "5" } );   // false
Jel.Validator.neq("4", { compare: "5" } ); // { value: 4 }

intLt

intLt: function(value,
info)

checks if a string value is less than another, comparing both as integers

Arguments

valuestring, the string to check
infoobject hash, required (see below)

Info hash Properties

comparethe value to compare to
inclusive (optional)whether the comparison includes the comparison value.  In this case, assumed to be false if not specified

Returns

objecta hash containing the integer value of the string, if the comparison is true { value: [typed-value] }, and the values are both integers
falseotherwise

Example

Jel.Validator.intLt("5", { compare: "6" } );   // { value: 5 }
Jel.Validator.intLt("4", { compare: "3" } ); // false

intGt

intGt: function(value,
info)

checks if a string value is greater than another, comparing both as integers

Arguments

valuestring, the string to check
infoobject hash, required (see below)

Info hash Properties

comparethe value to compare to
inclusive (optional)whether the comparison includes the comparison value.  In this case, assumed to be false if not specified

Returns

objecta hash containing the integer value of the string, if the comparison is true { value: [typed-value] }, and the values are both integers
falseotherwise

Example

Jel.Validator.intGt("5", { compare: "5" } );   // false
Jel.Validator.intGt("5", { compare: "4" } ); { value: 5 }

intLe

intLe: function(value,
info)

checks if a string value is less than or equal to another, comparing both as integers

Arguments

valuestring, the string to check
infoobject hash, required (see below)

Info hash Properties

comparethe value to compare to

Returns

objecta hash containing the integer value of the string, if the comparison is true { value: [typed-value] }, and the values are both integers
falseotherwise

Example

Jel.Validator.intLe("5", { compare: "5" } );   // { value: 5 }
Jel.Validator.intLe("4", { compare: "3" } ); // false

intGe

intGe: function(value,
info)

checks if a string value is greater than or equal to another, comparing both as integers

Arguments

valuestring, the string to check
infoobject hash, required (see below)

Info hash Properties

comparethe value to compare to

Returns

objecta hash containing the integer value of the string, if the comparison is true { value: [typed-value] }, and the values are both integers
falseotherwise

Example

Jel.Validator.intGe("5", { compare: "5" } );   // { value: 5 }
Jel.Validator.intGe("2", { compare: "3" } ); // false

intRange

intRange: function(value,
info)

checks if a string value falls within a given range, comparing as integers

Arguments

valuestring, the string to check
infoobject hash, required (see below)

Info hash Properties

lowerthe lower bound of the range to check
upperthe upper bound of the range to check
inclusive (optional)whether the comparison includes the lower and upper bounds.  Assumed to be true if not specified

Returns

objecta hash containing the native value of the string provided based on the type specified, if the comparison is true { value: [typed-value] }
falseotherwise

Example

Jel.Validator.intRange("3", { lower: "5", upper: "7" } );   // false
Jel.Validator.intRange("5", { lower: "4", upper: "8" } ); // { value: 5 }

floatEq

floatEq: function(value,
info)

checks if a string value is equal to another, comparing both as floats

Arguments

valuestring, the string to check
infoobject hash, required (see below)

Info hash Properties

comparethe value to compare to

Returns

objecta hash containing the float value of the string, if the comparison is true { value: [typed-value] }, and the values are both floats
falseotherwise

Example

 Jel.Validator.floatEq("5", { compare: "5.0" } );
// { value: 5.0 }

Jel.Validator.floatEq("4", { compare: "5.0" } );
// false

floatNeq

floatNeq: function(value,
info)

checks if a string value is not equal to another, comparing both as floats

Arguments

valuestring, the string to check
infoobject hash, required (see below)

Info hash Properties

comparethe value to compare to

Returns

objecta hash containing the float value of the string, if the comparison is true { value: [typed-value] }, and the values are both floats
falseotherwise

Example

 Jel.Validator.floatNeq("5", { compare: "5.0" } );
// false

Jel.Validator.floatNeq("4", { compare: "5.0" } );
// { value: 4.0 }

floatLt

floatLt: function(value,
info)

checks if a string value is less than another, comparing both as floats

Arguments

valuestring, the string to check
infoobject hash, required (see below)

Info hash Properties

comparethe value to compare to
inclusive (optional)whether the comparison includes the comparison value.  In this case, assumed to be false if not specified

Returns

objecta hash containing the float value of the string, if the comparison is true { value: [typed-value] }, and the values are both floats
falseotherwise

Example

Jel.Validator.floatLt("5", { compare: "6.0" } );   // { value: 5.0 }
Jel.Validator.floatLt("4", { compare: "3.0" } ); // false

floatGt

floatGt: function(value,
info)

checks if a string value is greater than another, comparing both as floats

Arguments

valuestring, the string to check
infoobject hash, required (see below)

Info hash Properties

comparethe value to compare to
inclusive (optional)whether the comparison includes the comparison value.  In this case, assumed to be false if not specified

Returns

objecta hash containing the float value of the string, if the comparison is true { value: [typed-value] }, and the values are both floats
falseotherwise

Example

Jel.Validator.floatGt("5.0", { compare: "5.0" } );   // false
Jel.Validator.floatGt("5.0", { compare: "4.0" } ); { value: 5.0 }

floatLe

floatLe: function(value,
info)

checks if a string value is less than or equal to another, comparing both as floats

Arguments

valuestring, the string to check
infoobject hash, required (see below)

Info hash Properties

comparethe value to compare to

Returns

objecta hash containing the float value of the string, if the comparison is true { value: [typed-value] }, and the values are both floats
falseotherwise

Example

Jel.Validator.floatLe("5.0", { compare: "5.0" } );   // { value: 5.0 }
Jel.Validator.floatLe("4.2", { compare: "3.0" } ); // false

floatGe

floatGe: function(value,
info)

checks if a string value is greater than or equal to another, comparing both as floats

Arguments

valuestring, the string to check
infoobject hash, required (see below)

Info hash Properties

comparethe value to compare to

Returns

objecta hash containing the float value of the string, if the comparison is true { value: [typed-value] }, and the values are both floats
falseotherwise

Example

Jel.Validator.floatGe("5.0", { compare: "5.0" } );   // { value: 5.0 }
Jel.Validator.floatGe("2.0", { compare: "3.0" } ); // false

floatRange

floatRange: function(value,
info)

checks if a string value falls within a given range, comparing as floats

Arguments

valuestring, the string to check
infoobject hash, required (see below)

Info hash Properties

lowerthe lower bound of the range to check
upperthe upper bound of the range to check
inclusive (optional)whether the comparison includes the lower and upper bounds.  Assumed to be true if not specified

Returns

objecta hash containing the native value of the string provided based on the type specified, if the comparison is true { value: [typed-value] }
falseotherwise

Example

Jel.Validator.floatRange("3.0", { lower: "5.0", upper: "7.0" } );   // false
Jel.Validator.floatRange("5.0", { lower: "4.0", upper: "8.0" } ); // { value: 5.0 }

numericEq

numericEq: function(value,
info)

checks if a string value is equal to another, comparing both as numeric (float or integer)

Arguments

valuestring, the string to check
infoobject hash, required (see below)

Info hash Properties

comparethe value to compare to

Returns

objecta hash containing the date value of the string, if the comparison is true { value: [typed-value] }, and the values are both dates
falseotherwise

Example

Jel.Validator.numericEq("5", { compare: "5.0" } );   // { value: 5.0 }
Jel.Validator.numericEq("4", { compare: "5.0" } ); // false

numericNeq

numericNeq: function(value,
info)

checks if a string value is not equal to another, comparing both as numeric (float or integer)

Arguments

valuestring, the string to check
infoobject hash, required (see below)

Info hash Properties

comparethe value to compare to

Returns

objecta hash containing the date value of the string, if the comparison is true { value: [typed-value] }, and the values are both dates
falseotherwise

Example

Jel.Validator.numericNeq("5", { compare: "5.0" } );   // false
Jel.Validator.numericNeq("4", { compare: "5.0" } ); // { value: 4.0 }

numericLt

numericLt: function(value,
info)

checks if a string value is less than another, comparing both as numeric (float or integer)

Arguments

valuestring, the string to check
infoobject hash, required (see below)

Info hash Properties

comparethe value to compare to
inclusive (optional)whether the comparison includes the comparison value.  In this case, assumed to be false if not specified

Returns

objecta hash containing the numeric value of the string, if the comparison is true { value: [typed-value] }, and the values are both numeric (float or integer)
falseotherwise

Example

Jel.Validator.numericLt("5", { compare: "6.0" } );   // { value: 5.0 }
Jel.Validator.numericLt("4", { compare: "3.0" } ); // false

numericGt

numericGt: function(value,
info)

checks if a string value is greater than another, comparing both as numeric (float or integer)

Arguments

valuestring, the string to check
infoobject hash, required (see below)

Info hash Properties

comparethe value to compare to
inclusive (optional)whether the comparison includes the comparison value.  In this case, assumed to be false if not specified

Returns

objecta hash containing the numeric value of the string, if the comparison is true { value: [typed-value] }, and the values are both numeric (float or integer)
falseotherwise

Example

Jel.Validator.numericGt("5.0", { compare: "5.0" } );   // false
Jel.Validator.numericGt("5.0", { compare: "4.0" } ); { value: 5.0 }