We have validation rules written in Drools at a backend. Rules are written against Domain model.
We would like to have rules at one place only. So we have created class which looks like:
public class ModelItem<T> {
private String userInput;
private T value;
....
}
And we've extended converters so If conve...
Form validation with jQuery is as easy as adding a classname to a field. Form validation with rails is as easy as putting a condition in to your controller (and/or model).
I figure there should be a way to write the validations once and have them applied both client and server side. I've always been a fan of writing my own javascript,...
In a Doctrine Record object, I can add the following method to validate data:
protected function validate()
{
if (empty($this->first_name) && empty($this->last_name) && empty($this->company)) {
$this->getErrorStack()->add('company', 'You must fill in at least one of the following: First Name, Last Name, Company');
}
}
...
I feel like I am fighting against the current when I develop ASP.NET Webform apps. I frequently run into the same problems, and while I eventually find some kind of workaround i'm never fully satisfied with the results.
Here is an example of a typical problem:
The design requires a grid or grid-like result set. This result set is pul...
I'm shifting code from an application built in a non-standard custom PHP framework into Ruby on Rails (version 3). In the PHP version all the controllers are really fat, with thin models, which I've always disagreed with, so I'm enjoying the way Rails does validation at the model level, which is probably 90% of what's happening in these...
I'm trying to setup data annotation validation for an object in my model and it has a special need. I have to essentially take some extra properties that I'm adding and combine them to get the value of a real property. For example I have a base object:
Task {
public DateTime? Due
}
But my form has the fields of:
Task.DueDate
Task...
Hello,
I am creating a website with Zend_Form. In my controller, I assign a form object to the view. In the view, I use the following code to render the form:
<?php if ( isset( $this->success ) ): ?>
<div class="message success"><p>Thanks!</p></div>
<?php elseif ( sizeof( $this->form->getMessages( ) ) > 0 ): ?>
<div class="mess...
I have the following class
public partial class Contact
{
public Contact()
{
}
#region Primitive Properties
public virtual int Id { get; set; }
[Display(ResourceType = typeof(Common), Name = "Person_Name")]
[Required(ErrorMessageResourceName = "Validation_Required", ErrorMessageResourceType = typeof(Common...
placing an error after an input box is simple and makes sense... but what if the error relates to a radio group and that group is within a table?
I want the error to show up after the table...
Any idea how to accomplish this?
...
I know there are quite some threads talking about validating XML file against its XML schema, such as : validate-xml-using-libxml and xml-schema-validation-with-relaxng
So if there is a simple Perl module on CPAN that can test this with minimal code, then that would be very fantastic to know.
...
I need to make a Rails form that responds back to the user live as they input fields.
Specifically, the user will need to input four decimal fields representing data from some tests our company runs. The problem is that the testers often input incorrectly (leave out a digit, or hit a '4' instead of a '1', etc).
This is easy to check, ...
So suppose I have the Person and Child models:
class Person < ActiveRecord::Base
has_many :children
accepts_nested_attributes_for :children
end
class Child < ActiveRecord::Base
belongs_to :parent, :class_name => "Person"
validates_presence_of :name
end
Now when I use a nested form and save a Person with 2 new children...
I'm quite new to asp.net mvc, and right know I'm trying to find out
a good practise to do input validation.
In the project we're going to use entity framework, where you can add
data annotations to properties in the following way:
[Required(ErrorMessage = "Please enter a product name")]
[Column]
public string Name { get; set; }
This...
A couple of my model classes are getting a little cluttered with all these "validates" calls, so I thought I'd be able to move them into a separate class and 'require' that, but it doesn't seem to work.
class Auction < ActiveRecord::Base
require 'auction/validations'
...
class Auction::Validations
include ActiveModel::Validations...
I am looking at the best way to take advantage of the MVC validation while using Ajax and not having access to a class.
On my masterpage it will contain a simple form (name, email, tel, comments) which I display in a overlay. As this is in the masterpage is available on any page, The masterpage never inherits a class like you would do w...
Hi,
I'm working on an ASP.NET MVC 2 project with some business entities that have metadata dataannotations attributes applied to them (Validation attributes, Display attributes, etc.).
Something like:
//User entity
public class User
{
[DisplayName("Vorname")]
[Required(ErrorMessage = "Vorname fehlt")]
...
I use simple js email validation like:
function validation(email) {
var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
return reg.test(email);
}
function check(){
if ($("#subemail").hasClass("bad")) {
var subemail = $("#subemail").val();
if((subemail!=0)&&validation(subemail)) {
...
I've got this object created from EntityFramework from my database.
[EdmEntityTypeAttribute(NamespaceName="ContactCoreModel", Name="TargetLang")]
[Serializable()]
[DataContractAttribute(IsReference=true)]
public partial class TargetLang : EntityObject
{
#region Factory Method
/// <summary>
/// Create a new TargetLang object...
I'd like to highlight field names instead of showing a separate error message when there is a validation error.
Is there any convenient way of doing this other than checking the ModelState Errors collection and wrapping each .LabelFor() in an if?
Also, I'd like to format labels as either bold, or add an asterisk if the model metadata h...
Is it possible to use the java.util.Calendar in a Struts2 IntRangeFieldValidator?
The following code does not produce any OGNL errors but does not work either. I'm trying to create a validation rule for a year range, min= 1970 and max= current calendar year.
@RequiredFieldValidator(message="Year cannot be blank")
@IntRangeFieldValidato...