PR comment followups (isNonEmptyString and rename WorkflowExecutionResult) (#13706)
Addressing two comments from Thomas and Charles
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { HttpService } from '@nestjs/axios';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
|
||||
import { isNonEmptyString } from '@sniptt/guards';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
import {
|
||||
@@ -37,13 +38,13 @@ export class GeoMapService {
|
||||
country?: string,
|
||||
isFieldCity?: boolean,
|
||||
): Promise<AutocompleteSanitizedResult[] | undefined> {
|
||||
if (!isDefined(address) || address.trim().length === 0) {
|
||||
if (!isNonEmptyString(address?.trim())) {
|
||||
return [];
|
||||
}
|
||||
|
||||
let url = `https://maps.googleapis.com/maps/api/place/autocomplete/json?input=${encodeURIComponent(address)}&sessiontoken=${token}&key=${this.apiMapKey}`;
|
||||
|
||||
if (isDefined(country) && country !== '') {
|
||||
if (isNonEmptyString(country)) {
|
||||
url += `&components=country:${country}`;
|
||||
}
|
||||
if (isDefined(isFieldCity) && isFieldCity === true) {
|
||||
|
||||
+2
-1
@@ -1,7 +1,8 @@
|
||||
import { isNonEmptyString } from '@sniptt/guards';
|
||||
import { ValidateIf, ValidationOptions, isDefined } from 'class-validator';
|
||||
|
||||
export function IsOptionalOrEmptyString(validationOptions?: ValidationOptions) {
|
||||
return ValidateIf((_obj, value) => {
|
||||
return isDefined(value) && value !== '';
|
||||
return isDefined(value) && isNonEmptyString(value);
|
||||
}, validationOptions);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user