import { IParseHandler , IParseProps } from '../../types' ; import { DataUtility } from '../../utility' ; import { ActionParamException } from '../exceptions' ; import { HandlerConstants , ActionParamExceptionCode } from './constants' ; Throws export const toInteger = ( props ) => { const val = DataUtility . toInteger ( props . value ) ; if ( ! ( val . isValid ) ) { throw new ActionParamException ( props . value , props . key , props . action , props . controller . constructor . name , ActionParamExceptionCode . integer , HandlerConstants . toInteger ) ; } return val . value ; } ; Throws export const toNumber = ( props ) => { const val = DataUtility . toNumber ( props . value ) ; if ( ! ( val . isValid ) ) { throw new ActionParamException ( props . value , props . key , props . action , props . controller . constructor . name , ActionParamExceptionCode . number , HandlerConstants . toNumber ) ; } return val . value ; } ; Throws export const toBoolean = ( props ) => { const val = DataUtility . toBoolean ( props . value ) ; if ( ! ( val . isValid ) ) { throw new ActionParamException ( props . value , props . key , props . action , props . controller . constructor . name , ActionParamExceptionCode . boolean , HandlerConstants . toBoolean ) ; } return val . value ; } ; /**
 * Does not perform any conversion or validation. Retrieves the original value.
 */ export const toValue = ( props ) => { return props . value ; } ; Throws export const toRegExp = ( props ) => { const regex = props . data ; if ( regex . test ( props . value ) ) return props . value ; throw new ActionParamException ( props . value , props . key , props . action , props . controller . constructor . name , ActionParamExceptionCode . regexp , `${ HandlerConstants . toRegExp } ${ props . data }` ) ; } ;