export const isNonEmptyString = ( v , trim = true ) : v is string => { return typeof v === 'string' && ( trim ? v . trim ( ) : v ) . length > 0 ; } ; export const isPlainObject = < T = unknown , K extends string | number = string > ( v ) : v is Record < K , T > => { return ( typeof v === 'object' && v !== null && v . constructor === Object && Object . getPrototypeOf ( v ) === Object . prototype ) ; } ; export const isSafeInteger = ( v ) : v is number => { return typeof v === 'number' && Number . isSafeInteger ( v ) ; } ; export const isParsableNumeric = ( v ) : v is number | string => { if ( typeof v === 'number' && ! Number . isNaN ( v ) ) { return true ; } if ( ! isNonEmptyString ( v ) ) { return false ; } return ! Number . isNaN ( Number . parseInt ( v , 10 ) || Number . isNaN ( Number . parseFloat ( v ) ) ) ; } ; export const isParsableSafeInteger = ( v ) : v is number | string => { const value = typeof v === 'string' && /^-?\d+$/ . test ( v ) ? Number . parseInt ( v , 10 ) : v ; return isSafeInteger ( value ) ; } ; export const isHttpStatusCode = ( v ) : v is number => { return isSafeInteger ( v ) && v < 600 && v >= 100 ; } ;