validation

Shoulda testing format

I am trying to test a model's attributes for formatting with this: # myapp/test/unit/comment_test.rb require 'test_helper' class CommentTest < ActiveSupport::TestCase should_belong_to :article should_validate_presence_of :name should_validate_presence_of :email should_validate_presence_of :content should_validate_presence_of...

JQuery Validation Plugin not working when used on page that includes another page via AJAX

We have a long page that contains a bunch of different form elements. One part of the form is called remotely via AJAX and is populated in an empty div. This is the part which JQuery Validation plugin is not working correctly on. We have class="required" on the elements on this page, but they do not show up as required. I'm guessing it...

Oval Validation

Can we access request object in isSatisfied() (class net.sf.oval.AbstractAnnotationCheck) method or can we pass an extra parameter in this method to use further. I have a scenario where I need to pass locale information to isSatisfied() method and apply some conditions. ...

"potentially dangerous Request.Form value ..." -- mvc 2, .net 4.0

Hi -- I am trying to set up input validation using regular expressions, but I keep getting this error when I enter "<test>" in a textbox: A potentially dangerous Request.Form value was detected from the client I have this in the web.config: <system.web> <httpRuntime requestValidationMode="2.0" /> I also have this in the web.con...

C#: Sending emails in a secure way correctly

Experimented sending secure emails using C# and was wondering if I have understood things correctly. I currently have the following program: using System; using System.Net.Mail; using System.Net; using System.Security.Authentication; using System.Security.Cryptography.X509Certificates; using System.IO; using System.Net.Security; namesp...

Why does isNaN(123.) return false?

Hi, Why does the Javascript function call isNaN(123.) return false? (notice the dot (.) after 123). Is this a universally acceptable number or will it cause errors downstream? I'm validating whether a value is a valid decimal using isNaN along with split. Are there cross-browser issues with isNaN? Should I use a bespoke implementation?...

Jquery Validation Watermark

I am using jQuery validation plugin and Watermark plugin. The problem I am facing is when i applied a watermark to any input field for which validation is also applied then validations are failing For Example: <input type=text name=myinput class="required"> and I applied a watermark for this field in document ready function: $("#my...

Load page for validation but do not display it to user in ASP.NET

We have a site requiring users pay $2 to view the details of a record. We occasionally get complaints because we send them to the payment page, and once they pay it turns out the record isn't valid, or it was lost, or the data couldn't be generated. So we want to add in a check to ensure the page constructs properly before the user is re...

Can I use MVC validation attributes within a custom model binder?

I have lots of MVC validation attributes on my model. Everything works great when the defaultModelBinder binds my model on submit. But, I need to create a custom modelbinder. I'd like to continue using my validation attributes. Can I? If so, how? ...

check if a line is valid or not in Java

I would like to perform checking on the following: VALID LINES; /**/ some code */ some code /** dsfsdkf sd**/ NOT VALID LINES; /**/ //some code */ /***/ //somecode So basically if there is a line of code outside a comment it is valid, otherwise not. What would be the best way to tackle this kind of validation? Note: For */ I ...

Is it possible to group validation?

I am using a lot of my own validation methods to compare the data from one association to the other. I've noticed that I'm constantly checking that my associations aren't nil before trying to call anything on them, but I am also validating their presence, and so I feel that my nil checks are redundant. Here's an example: class House <...

Restrict allowed file upload types PHP

Right now I have a function which takes my uploaded file, checks the extension, and if it matches an array of valid extensions it's processed. It's a contact list importer. What I need to figure out is how to be sure that file (in this case a .csv) is actually what it says it is (ex. not an excel file that just got renamed as a .csv). ...

Form validation Issue

I am using jQuery validation plugin for form validation. The problem I am facing is when I have inline labels.. For Example: <input type="text" name="myinput" value="Enter your ...."> This is the sample case where validation is failing because the 'value' is set for input field. Is there any workaround? How do I ignore default/label ...

Validation framework for .NET Compact Framework 3.5.

Do you know of a fast and simple entity validation framework that could be used in a Compact Framework project? I've done some experiments with FluentValidation (using db4o System.Linq.Expressions, but it's rather slow) and EViL (but it seems a bit half-baked). Can you suggest any other or maybe point me to some resources on how to d...

Hibernate Schema Validation Fails on Oracle Table Synonyms

I'm developing a Java web application that uses Hibernate (annotations-based) for persisting entities to an Oracle 11g database. The DBA created synonyms for the tables and requested that I use these synonyms instead of the physical tables. (Eg: Table "Foo" has synonym "S_Foo") If I have "hibernate.hbm2ddl.auto=validate" enabled, then ...

How to prevent PostBack on the client side?

I have some validation JS code on client, that must be executed befor PostBack. If this validation code return 'false', postback is needless. How it can be disabled? ...

Common function for self.errors.add_to_base in rails.

In my every model i have 10 or more lines for self.errors.add_to_base. is there any other way i can manage those lines in more easy way? will it possible to manage those errors with some common function which can handle self.errors.add_to_base for any of my model? Function like def error_add_to_base(message,conditions) self.errors...

javascript validation: comparing 2 text box values

I have a table with 5 rows and 2 columns. Each cell contains a text box. I want to show error if one of the text boxes in each column is empty. I want both text boxes in a row shld be filled or both shld empty. How can i do this via Asp.net validation controls? I want to extend CompareValidator so that it will validate only if the cont...

PHP: File exists and is in a certain sub-directory

I get a file path to a user file and I want to make sure that this path is to a valid existing user file and not to something bogus or a system file or something like that. I know I can use file_exists to check that it exists, but I'm not sure how I should make sure that the file is in a certain sub-directory... ...

ASP .net validations

For validation in ASP.Net which one is better validation controls or JavaScript coding ...