WEB-638 fix: improve core utility logic and migrate from deprecated substr (#3062)
improve
This commit is contained in:
@@ -18,7 +18,7 @@ export class Commons {
|
||||
let sortOrder = 1;
|
||||
if (property[0] === '-') {
|
||||
sortOrder = -1;
|
||||
property = property.substr(1);
|
||||
property = property.substring(1);
|
||||
}
|
||||
return (a: any, b: any) => {
|
||||
const result = a[property] < b[property] ? -1 : a[property] > b[property] ? 1 : 0;
|
||||
|
||||
@@ -29,7 +29,8 @@ export class Dates {
|
||||
}
|
||||
|
||||
public formatDateAsString(value: Date, dateFormat: string): string {
|
||||
return moment(value).format(dateFormat);
|
||||
const momentFormat = dateFormat.replace(/y/g, 'Y').replace(/d/g, 'D').replace(/a/g, 'A');
|
||||
return moment(value).format(momentFormat);
|
||||
}
|
||||
|
||||
public parseDate(value: any): Date {
|
||||
@@ -45,7 +46,8 @@ export class Dates {
|
||||
}
|
||||
|
||||
public convertToDate(value: any, format: string): Date {
|
||||
return moment(value).toDate();
|
||||
const momentFormat = format.replace(/y/g, 'Y').replace(/d/g, 'D').replace(/a/g, 'A');
|
||||
return moment(value, momentFormat).toDate();
|
||||
}
|
||||
|
||||
get language() {
|
||||
|
||||
@@ -16,10 +16,10 @@ import { environment } from '../../../environments/environment';
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class PasswordsUtility {
|
||||
minPasswordLength: number = environment.minPasswordLength | 12;
|
||||
minPasswordLength: number = environment.minPasswordLength || 12;
|
||||
public static PASSWORD_REGEX =
|
||||
'^(?!.*(.)\\1)(?!.*\\s)(?=.*\\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[^\\w\\s]).{' +
|
||||
(environment.minPasswordLength | 12) +
|
||||
(environment.minPasswordLength || 12) +
|
||||
',50}$';
|
||||
|
||||
public getPasswordValidators(): ValidatorFn[] {
|
||||
|
||||
Reference in New Issue
Block a user