Upgrade Guide
Upgrading To 3.* From <= 2.*
Test Properties
Each rule that is tested will now have it’s own property in the result i.e.
Consider the following code:
var rule = {
required: true
};
var result = approve.value('lorem ipsum', rule);
The result will now look like:
{
approved: boolean,
errors: [],
failed: [],
required: {
approved: boolean,
errors: []
}
}
This allows you easier access to specific test results.
As a result of the above, tests such as strength that return its own additional properties are no longer merged with the main result object, but instead are now part of the test’s own properties i.e.
Before v3.*
{
approved: boolean,
errors: [],
failed: [],
strength: string,
points: integer,
isMinimum: boolean,
hasLower: boolean,
hasUpper: boolean,
hasNumber: boolean,
hasSpecial: boolean,
isBonus: boolean,
percent: integer
}
From v3.*
{
approved: boolean,
errors: [],
failed: [],
strength: {
strength: string,
points: integer,
isMinimum: boolean,
hasLower: boolean,
hasUpper: boolean,
hasNumber: boolean,
hasSpecial: boolean,
isBonus: boolean,
percent: integer
}
}
Upgrading To 2.* From <= 1.*
Date Test
The date test now expects a format parameter when testing a value. The format can either be ymd for testing [YY]YY[-/]MM[-/]DD or dmy when testing for DD[-/]MM[-/][YY]YY.
Upgrading To 1.* From <= 0.0.6
Strength Test
The only major changes made is to the strength test. The resulting properties after running this test has been renamed to make more sense and moved from the nested .score object to the root of the result.
Consider the following code:
var rule = {
strength: {
min: 8,
bonus: 10
}
};
var result = approve.value('some text', rule);
The result (< v1) would look like the following:
{
approved: false,
errors: [],
message: 'Weak',
minimum: 8,
minimumBonus: 10,
score: {
value: 1,
isMinimum: true,
hasLower: true,
hasUpper: false,
hasNumber: false,
hasSpecial: false,
isBonus: false,
strength: 0
}
}
From v1.* the result will now be:
{
approved: false,
errors: [],
strength: 'Weak',
points: 1,
isMinimum: true,
hasLower: true,
hasUpper: false,
hasNumber: false,
hasSpecial: false,
isBonus: false,
percent: 0
}
result.messageis nowresult.strengthresult.score.valueis nowresult.pointsresult.score.isMinimumis nowresult.isMinimumresult.score.hasLoweris nowresult.hasLowerresult.score.hasUpperis nowresult.hasUpperresult.score.hasNumberis nowresult.hasNumberresult.score.hasSpecialis nowresult.hasSpecialresult.score.isBonusis nowresult.isBonusresult.score.strengthis nowresult.percent
Versioning
I initially used a custom versioning system, but to avoid confusion and follow the standard, ApproveJs will now follow proper semantic versioning (semver).