URL validation regular expression
Rules
- The string should start with either http or https followed by ://.
- The combined length of the sub-domain and root domain must be between 2 and 256. It should only contain alphanumeric characters and/or special characters.
- The TLD (Top-Level Domain) should only contain alphabetic characters and it should be between two and six characters long.
- The end of the URL string could contain alphanumeric characters and/or special characters. And it could repeat zero or more times.
Invokes a callback method when a class property is set
import { OnChange } from '@lerado/typescript-toolbox';
class MyClass {
@OnChange(function(changes) {
console.log(changes);
})
property1 = 0;
@OnChange(function(changes) {
console.log(changes);
})
property1 = 0;
}
the callback function
Performs a breadth-first traversal of a tree-like structure and returns the march of the traversal
import { breadthFirstTraversal } from '@lerado/typescript-toolbox';
const tree = {
id: 1,
children: [
{ id: 2, children: [ { id: 4 } ] },
{ id: 3, children: [ { id: 5 } ] }
]
};
breadthFirstTraversal(tree, 'children', console.log);
// => console: 1, 2, 3, 4, 5
// => [{ id: 1 }, { id: 2 }, { id: 3 }, { id: 4 }, { id: 5 }]
the tree's root object
accessor name for child elements
Performs a depth-first traversal of a tree-like structure and returns the march of the traversal
import { depthFirstTraversal } from '@lerado/typescript-toolbox';
const tree = {
id: 1,
children: [
{ id: 2, children: [ { id: 4 } ] },
{ id: 3, children: [ { id: 5 } ] }
]
};
depthFirstTraversal(tree, 'children', console.log);
// => console: 1, 2, 4, 3, 5
// => [{ id: 1 }, { id: 2 }, { id: 4 }, { id: 3 }, { id: 5 }]
the tree's root object
accessor name for child elements
Returns true if a given password is considered a strong password, false otherwise
import { isStrongPassword } from '@lerado/typescript-toolbox';
isStrongPassword('123456');
// => false
isStrongPassword('password123');
// => false
isStrongPassword('Password123');
// => false
isStrongPassword('Password!123');
// => true
string representing a password to check
Serializes an object. The idea is to serialize each object to a queryable string. This is very useful for search engines.
import { objectToFlatString } from '@lerado/typescript-toolbox';
objectToFlatString({ id: 123, name: 'Mr. Smith', age: 23 });
// => to 123mr. smith23.
Generates a strong password given a certain length (length >= 8
)
import { strongPassword } from '@lerado/typescript-toolbox';
strongPassword(7);
// => throws error: Can not create a strong password less than 8 characters long
strongPassword(8);
// => 8u5!W^g!
length of the generated password
Returns true if a given string is considered a valid URL, false otherwise
import { validateURL } from '@lerado/typescript-toolbox';
validateURL('https://www.linkedin.com/');
// => true
validateURL('http://apple');
// => false
validateURL('bullshit');
// => false
validateURL('https://w');
// => false
string representing a password to check
Generated using TypeDoc
Strong password regular expression
Rules
- at least eight characters long
- at least one capital letter
- at least one small letter
- at least one number
- at least one special character