Are booleans valid JSON

The validator you link to validates the JSON string existing of a mere true as invalid according to RFC 4627, which dictates that the root of a JSON string is to be an array or object: A JSON text is a serialized object or array. JSON-text = object / array An unwrapped value such as … Read more

Equivalent of IllegalArgumentException of Java in C++

Unlike Java, C++ does not have a “standard framework” but only a small (and optional) standard library. Moreover, there are different opinions under C++ programmers whether to use exceptions at all. Therefore you will find different recommendations by different people: Some like to use exception types from the standard library, some libraries (e.g. Poco) use … Read more

Remote Validation in ASP.Net MVC 3: How to use AdditionalFields in Action Method

Strange. It works for me: Model: public class MyViewModel { [Required] [Remote(“IsEmailAvailable”, “Home”, AdditionalFields = “InitialEmail”)] public string Email { get; set; } } Controller: public class HomeController : Controller { public ActionResult Index() { return View(new MyViewModel()); } [HttpPost] public ActionResult Index(MyViewModel model) { return View(model); } public ActionResult IsEmailAvailable(string email, string initialEmail) { … Read more

Customize spring validation error

The JSR 303 default message interpolation algorithm allows you to customize messages by supplying a resource bundle named ValidationMessages. Create a ValidationMessages.properties file in the classpath containing: javax.validation.constraints.NotNull.message=CUSTOM NOT NULL MESSAGE javax.validation.constraints.Size.message=CUSTOM SIZE MESSAGE This changes the default message for the @Size constraint, so you should use the @Size constraint instead of the Hibernate-specific @Length … Read more

Rails validation error messages: Displaying only one error message per field

[Update] Jan/2013 to Rails 3.2.x – update syntax; add spec Inspired by new validation methods in Rails 3.0 I’m adding this tiny Validator. I call it ReduceValidator. lib/reduce_validator.rb: # show only one error message per field # class ReduceValidator < ActiveModel::EachValidator def validate_each(record, attribute, value) return until record.errors.messages.has_key?(attribute) record.errors[attribute].slice!(-1) until record.errors[attribute].size <= 1 end end … Read more

rails built in datetime validation

There’s no built-in ActiveRecord validator for DateTimes, but you can easily add this sort of capability to an ActiveRecord model, without using a plugin, with something like this: class Thing < ActiveRecord::Base validate :happened_at_is_valid_datetime def happened_at_is_valid_datetime errors.add(:happened_at, ‘must be a valid datetime’) if ((DateTime.parse(happened_at) rescue ArgumentError) == ArgumentError) end end

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)