1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

update select to handle display property

This commit is contained in:
checktheroads
2021-03-17 12:39:35 -07:00
parent 9c66e1f01b
commit 4e837c2770
4 changed files with 299 additions and 173 deletions

View File

@ -4,6 +4,23 @@ export function isApiError(data: Record<string, unknown>): data is APIError {
return 'error' in data;
}
/**
* Type guard to determine if a value is not null, undefined, or empty.
*/
export function isTruthy<V extends string | number | boolean | null | undefined>(
value: V,
): value is NonNullable<V> {
const badStrings = ['', 'null', 'undefined'];
if (typeof value === 'string' && !badStrings.includes(value)) {
return true;
} else if (typeof value === 'number') {
return true;
} else if (typeof value === 'boolean') {
return true;
}
return false;
}
/**
* Retrieve the CSRF token from cookie storage.
*/