Returns an object that contains all the methods that can be used for input validations.
Methods
.arrow(end) Returns: boolean
Function to validate an arrow.
Name | Type | Description |
---|---|---|
end | string | An arrow's id |
Returns:
Returns true if the arrow is found, false otherwise.
Examples:
console.log(Vecta.valid.arrow('thick')); //true
console.log(Vecta.valid.arrow('thick.end')); //true
.arrowSize(val) Returns: boolean
Function to validate an arrow size.
Name | Type | Description |
---|---|---|
val | number | An arrow size. |
Returns:
Returns true if the arrow size is valid, false otherwise. Valid arrow size must be more than 0.
Examples:
console.log(Vecta.valid.arrowSize(20)); //true
.boolean(val) Returns: boolean
Function to validate a boolean value.
Name | Type | Description |
---|---|---|
val | boolean|number | A boolean value. Valid boolean values are limited to below:
|
Returns:
Returns true if the boolean value is valid, false otherwise.
Examples:
console.log(Vecta.valid.boolean(false)); //true
console.log(Vecta.valid.boolean(0)); //true
.color(color) Returns: boolean
Function to validate a color code
Name | Type | Description |
---|---|---|
color | string | A color code. Color code format is limited to below:
|
Returns:
Returns true if the color code is valid, false otherwise.
Examples:
console.log(Vecta.valid.color('#fff')); //true
console.log(Vecta.valid.color('rgba(255, 0, 0, 1)')); //true
console.log(Vecta.valid.color('blue')); //true
.dashArray(dash) Returns: boolean
Function to validate a stroke dash array value.
Name | Type | Description |
---|---|---|
dash | string | A dash array value. Valid dash arrays values are:
|
Returns:
Returns the dash array value if the dash array value is valid, false otherwise.
Examples:
console.log(Vecta.valid.dashArray('2 2')); //2 2
console.log(Vecta.valid.dashArray('none')); //false
.email(val) Returns: boolean
Function to validate email address
Name | Type | Description |
---|---|---|
val | string | The email to be validated |
Returns:
Returns true if value is a valid email address, false otherwise.
Examples:
var email = '[email protected]';
console.log(Vecta.valid.email(email)); //true
.font(font) Returns: boolean
Function to validate a font value.
Name | Type | Description |
---|---|---|
font | string | A font value. |
Returns:
Returns true if the font value is valid, false otherwise.
Examples:
console.log(Vecta.valid.font('Times New Roman')); //true
.fontSize(size) Returns: boolean
Function to validate a font size value.
Name | Type | Description |
---|---|---|
size | number|string | A font size value. If no value is provided, unit is default to px. Valid font size units are limited to below:
|
Returns:
Returns true if the font size value is valid, false otherwise.
Examples:
console.log(Vecta.valid.fontSize(9)); //true
console.log(Vecta.valid.fontSize('20 px')); //true
.fontStyle(style) Returns: boolean
Function to validate a font style value.
Name | Type | Description |
---|---|---|
style | string | A font style value. Valid font style values are limited to below:
|
Returns:
Returns true if the font style value is valid, false otherwise.
Examples:
console.log(Vecta.valid.fontStyle('italic')); //true
.fontWeight(weight) Returns: boolean
Function to validate a font weight value.
Name | Type | Description |
---|---|---|
weight | string | A font weight value. Valid font weight values are limited to below:
|
Returns:
Returns true if the font weight value is valid, false otherwise.
Examples:
console.log(Vecta.valid.fontWeight('bold')); //true
.increment(val) Returns: boolean
Function to validate the increment value.
Name | Type | Description |
---|---|---|
val | string | An increment value or regular expression string. |
Returns:
Returns true if the string is 'true', 'false'
or a Regular Expression, false otherwise.
Examples:
console.log(Vecta.valid.increment('true')); //true
.json(str) Returns: boolean
Function to validate a json.
Name | Type | Description |
---|---|---|
str | string | A string value. |
Returns:
Returns true if the string can be parsed to JSON, false otherwise.
Examples:
console.log(Vecta.valid.json('{"a": 1, "b": 2}')); //true
.lineCap(cap) Returns: boolean
Function to validate a line cap value.
Name | Type | Description |
---|---|---|
cap | string | A line cap value. Valid line cap values are limited to below:
|
Returns:
Returns true if the line cap value is valid, false otherwise.
Examples:
console.log(Vecta.valid.lineCap('round')); //true
.lineJoin(join) Returns: boolean
Function to validate a line join value.
Name | Type | Description |
---|---|---|
join | string | A line join value. Valid line join values are limited to below:
|
Returns:
Returns true if the line join value is valid, false otherwise.
Examples:
console.log(Vecta.valid.lineJoin('miter')); //true
.lineSpacing(space) Returns: boolean
Function to validate a line spacing value.
Name | Type | Description |
---|---|---|
space | number | A line spacing value, in digits only. |
Returns:
Returns true if the line spacing value is valid, false otherwise.
Examples:
console.log(Vecta.valid.lineSpacing(1.0)); //true
.link(link) Returns: boolean
Function to validate a link.
Name | Type | Description |
---|---|---|
link | string | A link from the Internet. |
Returns:
Returns true if the link is valid, false otherwise.
Examples:
console.log(Vecta.valid.link('https://vecta.io')); //true
.notEmpty(val) Returns: boolean
Function to validate if selection object is not empty
Name | Type | Description |
---|---|---|
val | string | A string value |
Returns:
Returns true if string is not empty, false otherwise.
Examples:
console.log(Vecta.valid.notEmpty('')); //false
console.log(Vecta.valid.notEmpty('Test')); //true
.number(str) Returns: boolean
Function to validate a number.
Name | Type | Description |
---|---|---|
str | number|string | A number or a number in string format. |
Returns:
Returns true if the value is valid, false otherwise.
Examples:
console.log(Vecta.valid.number('50')); //true
console.log(Vecta.valid.number(30)); //true
.opacity(opacity) Returns: boolean
Function to validate an opacity value.
Name | Type | Description |
---|---|---|
opacity | number | An opacity value. Valid opacity values are limited to the range from 0 to 1. |
Returns:
Returns true if the opacity value is valid, false otherwise.
Examples:
console.log(Vecta.valid.opacity(0.2)); //true
.percent(val) Returns: boolean
Function to validate percentages
Name | Type | Description |
---|---|---|
val | string | The percentage value to be validated |
Returns:
Returns true if value is a valid percentage, false otherwise.
Examples:
var percent = '90%';
console.log(Vecta.valid.percent(percent)); //true
.price(str) Returns: boolean
Function to validate whether a string is a price.
Name | Type | Description |
---|---|---|
str | number|string | A price number or string. Valid price format is limited to below: Only digits, decimals are allowed, and commas are allowed between digits before decimal places. |
Returns:
Returns true if the string is a price, false otherwise.
Examples:
console.log(Vecta.valid.price('50.00')); //true
console.log(Vecta.valid.price(40,000)); //true
.textAlign(align) Returns: boolean
Function to validate a text align value.
Name | Type | Description |
---|---|---|
align | string | A text align value. Valid text align values are limited to below:
|
Returns:
Returns true if the text align value is valid, false otherwise.
Examples:
console.log(Vecta.valid.textAlign('top')); //true
.textAnchor(anchor) Returns: boolean
Function to validate a text anchor value.
Name | Type | Description |
---|---|---|
anchor | string | A text anchor value. Valid text anchor values are limited to below:
|
Returns:
Returns true if the text anchor value is valid, false otherwise.
Examples:
console.log(Vecta.valid.textAnchor('middle')); //true
.textDecoration(decor) Returns: boolean
Function to validate a text decoration value.
Name | Type | Description |
---|---|---|
decor | string | A text decoration value. Valid text decoration values are limited to below:
|
Returns:
Returns true if the text decoration value is valid, false otherwise.
Examples:
console.log(Vecta.valid.textDecoration('underline')); //true
.textStrikeThrough(style) Returns: boolean
Function to validate a text strikethrough value.
Name | Type | Description |
---|---|---|
style | string | A text strikethrough value. Valid text strikethrough values are limited to below:
|
Returns:
Returns true if the text strikethrough value is valid, false otherwise.
Examples:
console.log(Vecta.valid.textStrikeThrough('line-through')); //true
.unit(length) Returns: boolean
Function to check if unit is valid
Name | Type | Description |
---|---|---|
length | string | The length to be validated. If no unit is provided, it is default to px. Valid units are limited to |
Returns:
Returns true if value is a valid unit value, false otherwise.
Examples:
console.log(Vecta.valid.unit(9)); //true
console.log(Vecta.valid.unit('9mm')); //true
console.log(Vecta.valid.unit('9 in')); //true