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 -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -