Hi Edward,
the problem is in conversion, not in validation. When a form value is filled by the user, it is a plain string. Then it arrives to Cocoon, that parse the string to convert it to the proper type, for example a date. After that conversion has been performed successfully, then validation is performed on the obtained converted value, for example the Date object.

So, it is not possible to check the string value from a validator, unless you are trying on a string field :)

You should be able to take the java source code of the date converter from a recent 2.1.x version of Cocoon, a version that supports the lenient attribute, and backport it to the 2.1.8 version.

Hope this helps,
Simone

Edward Elhauge wrote:
Hi,

I've run into a problem where my users want more detailed control over
Date field validation. In the version that we're running (2.1.8)
we don't have a "lenient" attribute for base="date" widgets.

So the user can type in "33/60/9z" as a date, which get converted into
"10/30/2011". Not what was expected.

What I'd like would be to a small:
  <fd:validation> <fd:javascript>
  ...
  </fd:javascript> </fd:validation>
section to throw an error in those cases.

Unfortunately this.value inside that javascript callback is already in a
Date format.

My question is:
  How do I get access to the users original text input
  within the fd:validation section?

  If there is no way to get access to the raw text, do I need to write
  my own validator to replace "FormattingDateConvertor" ?



--
Simone Gianni            CEO Semeru s.r.l.           Apache Committer
http://www.simonegianni.it/


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@cocoon.apache.org
For additional commands, e-mail: users-h...@cocoon.apache.org

Reply via email to