1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 """Abstract IValidator implementation that provides a basic IValidator
17 implementation except the isValid method."""
18
19 from muntjac.data.validator import InvalidValueException, IValidator
20
21
23 """Abstract L{IValidator} implementation that provides a basic IValidator
24 implementation except the L{isValid} method. Sub-classes need to implement
25 the L{isValid} method.
26
27 To include the value that failed validation in the exception message you
28 can use "{0}" in the error message. This will be replaced with the failed
29 value (converted to string using L{__str__}) or "null" if the value is
30 None.
31
32 @author: Vaadin Ltd.
33 @author: Richard Lincoln
34 @version: 1.1.2
35 """
36
38 """Constructs a validator with the given error message.
39
40 @param errorMessage:
41 the message to be included in an L{InvalidValueException}
42 (with "{0}" replaced by the value that failed validation).
43 """
44
45
46 self._errorMessage = errorMessage
47
48
53
54
56 """Returns the message to be included in the exception in case the
57 value does not validate.
58
59 @return: the error message provided in the constructor or using
60 L{setErrorMessage}.
61 """
62 return self._errorMessage
63
64
66 """Sets the message to be included in the exception in case the value
67 does not validate. The exception message is typically shown to the end
68 user.
69
70 @param errorMessage:
71 the error message. "{0}" is automatically replaced by the
72 value that did not validate.
73 """
74 self._errorMessage = errorMessage
75