similar to: validate_format_of message

Displaying 20 results from an estimated 8000 matches similar to: "validate_format_of message"

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,
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
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 =>
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
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
2012 Jan 19
0
Problem in testing with separate validation of :attachment_file_name
Using: RSpec, Shoulda, Paperclip (including matchers) Example Model class Example < ActiveRecord::Base has_attached_file :attachment validates_attachment_presence :attachment validates_format_of :attachment_file_name, :with => /\.(png|jpe?g)$/ end Example Test require ''spec/helper'' describe Example do it { should validate_attachment_presence(:attachment) }
2006 Jun 10
2
regex help
I am trying to write a model validates_format_of that will accept a field containing only certain characters. I want the field to only allow the following characters: a-z, A-Z, 0-9 and the ''_'', ''@'', ''.'' and ''-'' characters. I have hunted around a bit and came up with this: validates_format_of :password, :with =>
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 May 10
8
E-mail validtor??
Does anyone have a good working e-mail validator? or even some regexp to make the validates_format_of work right... that would be awesome. Also, maybe an online tutorial for regexp. i''ve always been afraid of it but i think it''s time to face the fears. thanks! -- Posted via http://www.ruby-forum.com/.
2006 Jan 19
4
validates_presence_of
I am just going through the book and I come across a problem with the code in the app/models: validates_format_of :image_url, :with => %r{^http:.+\.(gif|jpg|png)$}i, :message => "must be a URL for a GIF, JPG, or PNG image" It seems to moan when it''s empty even though I removed :image_url from validates_presence_of. How should I make it optional?
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
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 Jun 25
3
Dummy field in a model
I want to have a field in model, which I''m not storing in a database. And I want to do something like the following in the model code : validates_format_of :field_NOT_in_db, :with => session[:field] How can I do it ? Thanks, Pratik -- rm -rf / 2>/dev/null - http://null.in
2008 Mar 15
9
Spaces in Ruby on Rails and how to avoid them!
Hi, I just started learning ruby on rails and I am having hard time with white spacing! Here is the piece of code that will not work: validates_format_of :image_url, :with => %r{\.(gif|jpg|png)$}i, :message => "must be a URL for a GIF, JPG or PNG image" and here is the piece of code that will work: validates_format_of :image_url, :with => %r{\.(gif|jpg|png)$}i, :message
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 =
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 03
9
validating phone numbers
Anyone got a good validation for validating a phone number? I just want to make sure that whatever the user enters is somewhat sensical, and i''d like to be fairly liberal about what kind of a format it''s in. Joe
2006 Aug 14
3
validating required fields during an update?
I have a User model with an email attribute. I''m using the following validations: validates_confirmation_of :email validates_format_of :email, :with => RFC822::EmailAddress, :message => "must be a valid address in the form user@domain.com" validates_uniqueness_of :email, :message => "address has already been taken. If you''ve forgotten your
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
2007 Aug 07
2
Making Validations Optional
Hello, I am working with URL validations. I want this validation to be optional if the data exists in the form submission. I have tried several things. validates_format_of :website, :if => params[:organization][:website], :with => /((http|https):\/\/)?[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z] {2,5}(([0-9]{1,5})?\/.*)?/, :message => "Please enter a valid url" Of