Chore(front): Add more typeguards (#2136)
* Chore(front): Add more typeguards Co-authored-by: Benjamin Mayanja V <vibenjamin6@gmail.com> Co-authored-by: KlingerMatheus <klinger.matheus@gitstart.dev> * Remove source map generation to avoid warnings --------- Co-authored-by: Benjamin Mayanja V <vibenjamin6@gmail.com> Co-authored-by: KlingerMatheus <klinger.matheus@gitstart.dev> Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
@ -1,9 +1,8 @@
|
||||
import { isBoolean } from '@sniptt/guards';
|
||||
|
||||
import { FieldBooleanValue } from '../FieldMetadata';
|
||||
|
||||
// TODO: add yup
|
||||
export const isFieldBooleanValue = (
|
||||
fieldValue: unknown,
|
||||
): fieldValue is FieldBooleanValue =>
|
||||
fieldValue !== null &&
|
||||
fieldValue !== undefined &&
|
||||
typeof fieldValue === 'boolean';
|
||||
): fieldValue is FieldBooleanValue => isBoolean(fieldValue);
|
||||
|
||||
@ -1,9 +1,8 @@
|
||||
import { isString } from '@sniptt/guards';
|
||||
|
||||
import { FieldChipValue } from '../FieldMetadata';
|
||||
|
||||
// TODO: add yup
|
||||
export const isFieldChipValue = (
|
||||
fieldValue: unknown,
|
||||
): fieldValue is FieldChipValue =>
|
||||
fieldValue !== null &&
|
||||
fieldValue !== undefined &&
|
||||
typeof fieldValue === 'string';
|
||||
): fieldValue is FieldChipValue => isString(fieldValue);
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
import { isNull, isString } from '@sniptt/guards';
|
||||
|
||||
import { FieldDateValue } from '../FieldMetadata';
|
||||
|
||||
// TODO: add yup
|
||||
export const isFieldDateValue = (
|
||||
fieldValue: unknown,
|
||||
): fieldValue is FieldDateValue =>
|
||||
fieldValue === null ||
|
||||
(fieldValue !== undefined && typeof fieldValue === 'string');
|
||||
): fieldValue is FieldDateValue => isNull(fieldValue) || isString(fieldValue);
|
||||
|
||||
@ -1,9 +1,8 @@
|
||||
import { isString } from '@sniptt/guards';
|
||||
|
||||
import { FieldEmailValue } from '../FieldMetadata';
|
||||
|
||||
// TODO: add yup
|
||||
export const isFieldEmailValue = (
|
||||
fieldValue: unknown,
|
||||
): fieldValue is FieldEmailValue =>
|
||||
fieldValue !== null &&
|
||||
fieldValue !== undefined &&
|
||||
typeof fieldValue === 'string';
|
||||
): fieldValue is FieldEmailValue => isString(fieldValue);
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
import { isNull, isNumber } from '@sniptt/guards';
|
||||
|
||||
import { FieldMoneyValue } from '../FieldMetadata';
|
||||
|
||||
// TODO: add yup
|
||||
export const isFieldMoneyValue = (
|
||||
fieldValue: unknown,
|
||||
): fieldValue is FieldMoneyValue =>
|
||||
fieldValue === null ||
|
||||
(fieldValue !== undefined && typeof fieldValue === 'number');
|
||||
): fieldValue is FieldMoneyValue => isNull(fieldValue) || isNumber(fieldValue);
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
import { isNull, isNumber } from '@sniptt/guards';
|
||||
|
||||
import { FieldNumberValue } from '../FieldMetadata';
|
||||
|
||||
// TODO: add yup
|
||||
export const isFieldNumberValue = (
|
||||
fieldValue: unknown,
|
||||
): fieldValue is FieldNumberValue =>
|
||||
fieldValue === null ||
|
||||
(fieldValue !== undefined && typeof fieldValue === 'number');
|
||||
): fieldValue is FieldNumberValue => isNull(fieldValue) || isNumber(fieldValue);
|
||||
|
||||
@ -1,9 +1,8 @@
|
||||
import { isString } from '@sniptt/guards';
|
||||
|
||||
import { FieldPhoneValue } from '../FieldMetadata';
|
||||
|
||||
// TODO: add yup
|
||||
export const isFieldPhoneValue = (
|
||||
fieldValue: unknown,
|
||||
): fieldValue is FieldPhoneValue =>
|
||||
fieldValue !== null &&
|
||||
fieldValue !== undefined &&
|
||||
typeof fieldValue === 'string';
|
||||
): fieldValue is FieldPhoneValue => isString(fieldValue);
|
||||
|
||||
@ -1,9 +1,8 @@
|
||||
import { isNumber } from '@sniptt/guards';
|
||||
|
||||
import { FieldProbabilityValue } from '../FieldMetadata';
|
||||
|
||||
// TODO: add yup
|
||||
export const isFieldProbabilityValue = (
|
||||
fieldValue: unknown,
|
||||
): fieldValue is FieldProbabilityValue =>
|
||||
fieldValue !== null &&
|
||||
fieldValue !== undefined &&
|
||||
typeof fieldValue === 'number';
|
||||
): fieldValue is FieldProbabilityValue => isNumber(fieldValue);
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
import { isObject, isUndefined } from '@sniptt/guards';
|
||||
|
||||
import { FieldRelationValue } from '../FieldMetadata';
|
||||
|
||||
// TODO: add yup
|
||||
export const isFieldRelationValue = (
|
||||
fieldValue: unknown,
|
||||
): fieldValue is FieldRelationValue =>
|
||||
fieldValue !== undefined && typeof fieldValue === 'object';
|
||||
!isUndefined(fieldValue) && isObject(fieldValue);
|
||||
|
||||
@ -1,9 +1,8 @@
|
||||
import { isString } from '@sniptt/guards';
|
||||
|
||||
import { FieldTextValue } from '../FieldMetadata';
|
||||
|
||||
// TODO: add yup
|
||||
export const isFieldTextValue = (
|
||||
fieldValue: unknown,
|
||||
): fieldValue is FieldTextValue =>
|
||||
fieldValue !== null &&
|
||||
fieldValue !== undefined &&
|
||||
typeof fieldValue === 'string';
|
||||
): fieldValue is FieldTextValue => isString(fieldValue);
|
||||
|
||||
@ -1,9 +1,8 @@
|
||||
import { isString } from '@sniptt/guards';
|
||||
|
||||
import { FieldURLValue } from '../FieldMetadata';
|
||||
|
||||
// TODO: add yup
|
||||
export const isFieldURLValue = (
|
||||
fieldValue: unknown,
|
||||
): fieldValue is FieldURLValue =>
|
||||
fieldValue !== null &&
|
||||
fieldValue !== undefined &&
|
||||
typeof fieldValue === 'string';
|
||||
): fieldValue is FieldURLValue => isString(fieldValue);
|
||||
|
||||
Reference in New Issue
Block a user