Skip to content

Commit

Permalink
v1.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
rkuykendall committed Apr 29, 2019
1 parent 191e492 commit 0136d1e
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 17 deletions.
18 changes: 13 additions & 5 deletions dist/utils.cjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -22431,11 +22431,15 @@ function _varToLabel(str) {
suffix = str.split('.').pop() || '',
formatted = lodash.startCase(suffix);
return formatted.replace(/[A-Za-z0-9\u00C0-\u00FF]+[^\s-]*/g, function (match, index, title) {
if (index > 0 && index + match.length !== title.length && match.search(smallWords) > -1 && title.charAt(index - 2) !== ':' && (title.charAt(index + match.length) !== '-' || title.charAt(index - 1) === '-') && title.charAt(index - 1).search(/[^\s-]/) < 0) {
var notFirstWord = index > 0,
notOnlyWord = index + match.length !== title.length,
hasSmallWords = match.search(smallWords) > -1;

if (notFirstWord && notOnlyWord && hasSmallWords) {
return match.toLowerCase();
}

return match.charAt(0).toUpperCase() + match.substr(1);
return match.charAt(0).toUpperCase() + match.substr(1).toLowerCase();
});
}

Expand Down Expand Up @@ -27202,10 +27206,13 @@ function getPercentDisplay(value) {
return new Decimal(value).times(CENT_DECIMAL).toString();
}

function isValidBirthdate(value) {
function isValidDate(value) {
return !value || value.length === '####-##-##'.length // ISO date
&& moment(value).isValid() // Real day
&& moment(value).isBefore(moment()) // In the past
;
}
function isValidPastDate(value) {
return !value || isValidDate(value) && moment(value).isBefore(moment()) // In the past
;
}

Expand Down Expand Up @@ -27252,4 +27259,5 @@ exports.formatAddressMultiline = formatAddressMultiline;
exports.insertIf = insertIf;
exports.getPercentValue = getPercentValue;
exports.getPercentDisplay = getPercentDisplay;
exports.isValidBirthdate = isValidBirthdate;
exports.isValidDate = isValidDate;
exports.isValidPastDate = isValidPastDate;
17 changes: 12 additions & 5 deletions dist/utils.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -22424,11 +22424,15 @@ function _varToLabel(str) {
suffix = str.split('.').pop() || '',
formatted = startCase(suffix);
return formatted.replace(/[A-Za-z0-9\u00C0-\u00FF]+[^\s-]*/g, function (match, index, title) {
if (index > 0 && index + match.length !== title.length && match.search(smallWords) > -1 && title.charAt(index - 2) !== ':' && (title.charAt(index + match.length) !== '-' || title.charAt(index - 1) === '-') && title.charAt(index - 1).search(/[^\s-]/) < 0) {
var notFirstWord = index > 0,
notOnlyWord = index + match.length !== title.length,
hasSmallWords = match.search(smallWords) > -1;

if (notFirstWord && notOnlyWord && hasSmallWords) {
return match.toLowerCase();
}

return match.charAt(0).toUpperCase() + match.substr(1);
return match.charAt(0).toUpperCase() + match.substr(1).toLowerCase();
});
}

Expand Down Expand Up @@ -27195,11 +27199,14 @@ function getPercentDisplay(value) {
return new Decimal(value).times(CENT_DECIMAL).toString();
}

function isValidBirthdate(value) {
function isValidDate(value) {
return !value || value.length === '####-##-##'.length // ISO date
&& moment(value).isValid() // Real day
&& moment(value).isBefore(moment()) // In the past
;
}
function isValidPastDate(value) {
return !value || isValidDate(value) && moment(value).isBefore(moment()) // In the past
;
}

export { EMPTY_FIELD, DATE_FORMATS, CENT_DECIMAL, createDisabledContainer, createGuardedContainer, dateToday, isFutureDate, inferCentury, canReplaceSymbols, replaceSymbolsWithChars, hasStringContent, hasStringOrNumberContent, splitName, splitCommaList, formatFullName, formatPhoneNumber, formatDate, formatDateTime, getNameOrDefault, getOrDefault, formatSocialSecurityNumber, formatPercentage, formatMoney, formatParagraphs, formatCommaSeparatedNumber, formatDelimitedList, mapBooleanToText, formatMoneyInput, formatDuration, formatWebsite, stripNonAlpha, pluralize, getType, preserveNewLines, parseAndPreserveNewlines, getDisplayName, varToLabel, toKey, formatAddress, formatAddressMultiline, insertIf, getPercentValue, getPercentDisplay, isValidBirthdate };
export { EMPTY_FIELD, DATE_FORMATS, CENT_DECIMAL, createDisabledContainer, createGuardedContainer, dateToday, isFutureDate, inferCentury, canReplaceSymbols, replaceSymbolsWithChars, hasStringContent, hasStringOrNumberContent, splitName, splitCommaList, formatFullName, formatPhoneNumber, formatDate, formatDateTime, getNameOrDefault, getOrDefault, formatSocialSecurityNumber, formatPercentage, formatMoney, formatParagraphs, formatCommaSeparatedNumber, formatDelimitedList, mapBooleanToText, formatMoneyInput, formatDuration, formatWebsite, stripNonAlpha, pluralize, getType, preserveNewLines, parseAndPreserveNewlines, getDisplayName, varToLabel, toKey, formatAddress, formatAddressMultiline, insertIf, getPercentValue, getPercentDisplay, isValidDate, isValidPastDate };
18 changes: 13 additions & 5 deletions dist/utils.umd.js
Original file line number Diff line number Diff line change
Expand Up @@ -22427,11 +22427,15 @@
suffix = str.split('.').pop() || '',
formatted = lodash.startCase(suffix);
return formatted.replace(/[A-Za-z0-9\u00C0-\u00FF]+[^\s-]*/g, function (match, index, title) {
if (index > 0 && index + match.length !== title.length && match.search(smallWords) > -1 && title.charAt(index - 2) !== ':' && (title.charAt(index + match.length) !== '-' || title.charAt(index - 1) === '-') && title.charAt(index - 1).search(/[^\s-]/) < 0) {
var notFirstWord = index > 0,
notOnlyWord = index + match.length !== title.length,
hasSmallWords = match.search(smallWords) > -1;

if (notFirstWord && notOnlyWord && hasSmallWords) {
return match.toLowerCase();
}

return match.charAt(0).toUpperCase() + match.substr(1);
return match.charAt(0).toUpperCase() + match.substr(1).toLowerCase();
});
}

Expand Down Expand Up @@ -27198,10 +27202,13 @@
return new Decimal(value).times(CENT_DECIMAL).toString();
}

function isValidBirthdate(value) {
function isValidDate(value) {
return !value || value.length === '####-##-##'.length // ISO date
&& moment(value).isValid() // Real day
&& moment(value).isBefore(moment()) // In the past
;
}
function isValidPastDate(value) {
return !value || isValidDate(value) && moment(value).isBefore(moment()) // In the past
;
}

Expand Down Expand Up @@ -27248,7 +27255,8 @@
exports.insertIf = insertIf;
exports.getPercentValue = getPercentValue;
exports.getPercentDisplay = getPercentDisplay;
exports.isValidBirthdate = isValidBirthdate;
exports.isValidDate = isValidDate;
exports.isValidPastDate = isValidPastDate;

Object.defineProperty(exports, '__esModule', { value: true });

Expand Down
3 changes: 2 additions & 1 deletion dist/validation.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export declare function isValidBirthdate(value: string): boolean;
export declare function isValidDate(value: string): boolean;
export declare function isValidPastDate(value: string): boolean;
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mighty-justice/utils",
"version": "1.2.4",
"version": "1.3.0",
"description": "Standardization of small utilities across Mighty",
"main": "dist/utils.cjs.js",
"module": "dist/utils.esm.js",
Expand Down

0 comments on commit 0136d1e

Please sign in to comment.