regex - Rails - validates_format_of for datetime (mysql format) -


i'm having custom input field in simple_form user sets datetime bootstrap datetimepicker plugin

= f.input :published_at, as: :date_time_picker 

the datetime set in sql format, yyyy-mm-dd hh:ii:ss

now, 'd set validation, check datetime entered in correct format in case user tries type datetime instead of clicking calendar icon , choosing it

validates_format_of :published_at, with: /^((19|20)\\d\\d)-(0?[1-9]|1[012])-(0?[1-9]|[12][0-9]|3[01]) /i, allow_nil: true 

how can set format of time in case?


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

reflection - How to access the object-members of an object declaration in kotlin -

php - Doctrine Query Builder Error on Join: [Syntax Error] line 0, col 87: Error: Expected Literal, got 'JOIN' -