Displaying 20 results from an estimated 30000 matches similar to: "validates_format_of date"
2008 Jun 07
3
DRY validates_format_of?
In a model I have following validates_format_of. Is there an easy way to
DRY this up? It seems to be rather repetitive.
validates_format_of :expiration_date, :with =>
/^[0-9]{4}[-][0-9]{2}[-][0-9]{2}$/
validates_format_of :activation_date, :with =>
/^[0-9]{4}[-][0-9]{2}[-][0-9]{2}$/
validates_format_of :some_other_date, :with =>
2006 Sep 10
1
validates_format_of :something, :with => /REGEX/
Hi all,
I''m hoping to stir the Rails pot a little bit here, so please go easy
with me ;-)
Regular Expressions is the most densely inhumane language construct
ever invented in any ''civilisation'', and the fact that we still have
to dirty our minds with this in Rails is something that (sh/c)ould
ideally be corrected in Rails (preferably before the release of 1.2
2007 Feb 16
13
negate the regexp in validates_format_of
Railsters:
ActiveRecord''s validation system puts other database systems to shame.
However, the newbies might not know how to write a regexp that
excludes a match, instead of tests for it. Understand - I''m just
asking this question to help them. I have been using Regexps since
''grep'' on Xenix! But the newbies here might not know how to do this:
2006 Apr 05
4
validates_format_of ?
Hi all,
I''ve got a form which accepts a "price" field and I''m attempting to
validate it and allow some flexibility in the way the user enters it.
It''s a numeric field but I want the user to be able to enter dollar
signs and commas naturally in the data entry.
I''m trying to understand how to use validates_format_of, and I''m not
sure what
2005 Nov 28
4
validates_format_of nil
I''ve noticed that validates_format_of will return invalid if the field
is nil.
Question 1) How should we declare a validation that will validate it
with a regex if it is set, but, if the field is not set, just move on
Question 2) Why is it done this way? The other validators are only
invoked if the field is set . If you want to declare the field
mandatory, you add a
2012 Aug 14
3
validates_format_of :message not working, validates_length_of :message is working
I''m using validates_format_of and the validation I want to do works, but I
can''t get an error message to be displayed if the data is invalid:
validates_format_of :mobile, :with => /\A[\+0-9]+\Z/, :message => " - Wrong"
I have another validation some where else that does display the error
message: " - Name is too long"
validates_length_of :name,
2008 Feb 24
1
validates_format_of no dots allowed
I need a validates_format_of that disallow dots.
In the api there is nothing to find about how validates_format_of exatly
works.
Is there a better documentation or is there something that can tell me
howto disallow dots.
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
2006 Jun 14
1
file column validates_format_of
Been manually testing file column with success except it seems to upload
the file before validating it. Also .pdf files (which shouldn''t even
validate) crash WEBrick. What am I missing to solve these problems?
(apart from a brain!)
validates_presence_of :title, :file
validates_format_of :file, :with => %r{.(gif|jpg|png)$}i,
:message => "File must end with .jpg, .gif or
2006 Mar 17
0
validates_format_of before type_cast?
Often I need to do a one-off validation before Rails has had a chance to
convert. For example, a date. Is there a general mechanism to cause
validations to run on the raw input or do I have to resort to:
private
def validate
unless attributes_before_type_cast[''date_of_loss''] =~
/^(\d+(-|\/)){2}\d{4}/
errors.add(''date_of_loss'', ''use the
2005 Aug 10
5
validates_format_of on an optional field using :if
Hi there,
I''ve got the following in my model:
validates_format_of :postcode,
:with => /^([a-zA-Z]{1,2}[0-9]{1,2} [0-9]{1}[a-zA-Z]{2})$/,
:message => "is not valid",
:if => :postcode
... but it''s not working - it always insists on validation, even if postcode
is empty. Basically, the postcode field is optional, but if it''s filled in, I
want to
2006 Feb 22
0
validates_format_of datetime?
What''s the best way to check a field to ensure it is a valid datetime? I
could validates_format_of :with a regular expression for "yyyy-mm-dd
hh:mm:ss", but I''m wondering if there is a more direct way to do this.
--
Posted via http://www.ruby-forum.com/.
2006 Feb 27
1
Help on validates_format_of
Hello,
i''m quite new with Ruby and i''ve been headbreaking quite a while
on the following question. So I hope somebody can help this Noob on
Rails.
I want to use validates_format_of on the password a user enters for
his or her account. I want it to check on the following:
1.. The password has to have a minimum of 2 non-capitalized characters.
with the characters i mean: a
2006 Jan 20
4
validates_format_of > Invalid regular expression with simple pattern
Hello,
I try this :
validates_format_of :name , :with => /^[A-z0-9_.- ]*$/ , :message =>
"bad characters"
for accept any name with chars "A" to "z" , "0" to "9" , with "_" "."
"-" and " "
The pattern is really simple but I have this error :
SyntaxError in Login#register
2010 Jan 18
3
validates_format_of :phone,
validates_format_of :phone,
:with => /\A\s*(?:(?:\+?(?:\d{1,3}(?:\s*|[\-.])))?\(?\d{3}[\-\/)]?\s*)
(?:[2-9][0-9 \-.]{6,})\s*\z/,
i pit it on my reuriments but error whlie entering
666.111.9999
i want it should be ok
any one help me please
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to
2006 Jun 13
0
date_select and date validation
Hi,
I''ve put together a simple form that contains among other things a
date_select:
<%= date_select(:user, :dob, :order => [:day, :month, :year],
:start_year => 1900, :end_year => Date.today.year) %>
In my controller I have some code to create a user entity from the
parameters posted up from the form, like so:
parameters:
2001 Oct 15
0
date and chron library help...!
Dear all,
I'm not sure whether this is a bug or not... But some help would be greatly appreciated.
I have a dataframe, which I read in using read.xport (from the foriegn library) as the orginal data is in SAS format.
3 columns of this dataset are supposed to be dates, but read.xport doesn't recognise them as dates (all columns are read in as mode numeric). So I load up the date library
2010 Aug 16
1
How can I read date format '02-Jan-02' ?
Hello,
I am trying to read a database exported from SAS.
It is form of csv, and the date format reads '02-Feb-99'.
I used following code to convert character to date format,
db$dob<-as.Date(db$dob, format="%d-%b-%y").
but it doesn't work, only seems NA.
What's wrong with this code?
Thank you in advance.
Best,
Dong-Hee Koh
[[alternative HTML version deleted]]
2009 Feb 28
7
be_valid (validates_format_of ..., :on => :create)
Greetings,
How to write Example which will check if model''s variable''s
format is valid using :on => :create, like this:
class User < ActiveRecord::Base
...
validates_format_of :email, :with => /.../, :on => :create
...
Using following code is not right:
it "should ..." do
@user = users(:example_user)
@user.email =
2003 Jun 30
1
date to age
I have files which have columns of data that look like this:
DOB
9/27/1964
...
That is, dates in month/day/year format. When variables like DOB are read
in, they are converted to factors.
So, I wrote this to convert from date to age in years:
age<-function(x)
{as.numeric(Sys.time()-strptime(as.character(x),format="%m/%d/%Y"))/365.25}
This isn't very precise or pretty, but it
2011 Nov 07
2
Problem working with dates
Hello All,
I've been reading books about R for awhile now and am in the process of replicating the SAS analyses from an old report. I want to be sure that I can do all the things I need to in R before using it in my daily work.
So far, I've managed to read in all my data and have done some data manipulation. I'm having trouble with fixing an error in a date variable though, and was