开发者

Rails Validations, only integers for :price_in_cents

开发者 https://www.devze.com 2022-12-21 06:05 出处:网络
validates_开发者_如何学运维format_of :price_in_cents, :with => What is the regexp for this simple validationYou can use validates_numericality_of with only_integer, combined with positive numbers to

validates_开发者_如何学运维format_of :price_in_cents, :with =>

What is the regexp for this simple validation


You can use validates_numericality_of with only_integer, combined with positive numbers to represent price in pennies.


/[0-9]+/ Matches one or more integers, however there are better ways to do this (as seen in marklai's answer).

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号