Check string is a valid number or not in ruby -


I want to check the weather variable is a valid number or not.

I can validate correctly void and empty, but "could not accept the text as a whole" ...

I tried:

  if (Param [: Parama]. Blanc? ||: ParamA] .is_a? (int)))  

I also is_numeric, is_numeric (string) Have tried, is_number? And other ways ... but in vain ...

I noticed patches:

  Is square string def is_number? If the parameter [: Parama]: Blank? ||! Param [: Ultimate]. Ais_anmber?)  

or without patch:

P>

  if (params [: paramA] .blank? || ( false if the float (Param [[Parama]) Rescue)) the right  

the 12 , -12 , 12.12 , 1e-3 and so on.


Comments