Validating number using Ruby Regex -


working on rails project requires me validate number (representing day of month) either 1 or 15. placed following validation @ top of model:

validates :deposit_date, presence: true, format: { with: /\a1(5)?\z/ } 

the regex works intended when use irb or online testers, fails validation in rails app. number being passed string, don't think it's type issue.

update: thank of relevent answers quickly. able track down issue... data in db invalid, causing seperate save! call fail ;)

try removing capture of 5.

{ with: /\a15?\z/ } 

Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -