Added more comments and assertions to all classes; clean up

This commit is contained in:
severin
2014-03-19 16:49:24 +01:00
parent c5363c948c
commit 4e7e1e9c45
25 changed files with 223 additions and 83 deletions

View File

@@ -22,18 +22,25 @@ create
feature {NONE} -- Initialization
make (h: like handler; e: STRING_32)
-- Initialize with given validation function and error message
do
make_validator (e)
handler := h
ensure
handler_set: handler = h
end
feature
feature -- Implementation
is_valid (input: G): BOOLEAN
-- Tests if given input is valid
do
Result := handler.item ([input])
end
feature -- Properties
handler: FUNCTION [ANY, TUPLE [G], BOOLEAN]
-- The function which is used to validate inputs
end

View File

@@ -1,6 +1,9 @@
note
description: "[
Validator implementation which make sure that the input has a the format of an valid email address
Validator implementation which make sure that the input has
the format of an valid email address. This is just a very
basic implementation that tests if the given input contains
a '@'.
]"
author: ""
date: "$Date$"
@@ -22,7 +25,7 @@ create
feature {NONE} -- Initialization
make (e: STRING_32)
-- Initialize with specified error message which will be displayed on validation failure
-- Initialize with specified error message
do
make_regexp_validator ("^.*@.*$", e)
end

View File

@@ -29,6 +29,7 @@ feature {NONE} -- Initialization
make_validator (e)
regexp_string := r
create regexp
ensure regexp_string_set: regexp_string = r
end
feature -- Implementation
@@ -39,7 +40,6 @@ feature -- Implementation
if not regexp.is_compiled then
regexp.compile (regexp_string)
end
Result := (not input.is_empty) and regexp.matches (input)
end
@@ -56,7 +56,9 @@ feature -- State
feature -- Properties
regexp_string: STRING_32
-- The regexp in string representation
regexp: REGULAR_EXPRESSION
-- The regexp of this validator
end

View File

@@ -15,6 +15,8 @@ feature {NONE} -- Initialization
-- Initialize with specified error message to be displayed on validation failure
do
error := e
ensure
error_set: error = e
end
feature -- Access
@@ -35,5 +37,6 @@ feature -- Access
feature -- Properties
error: STRING_32
-- The error message if validation fails
end