Added Regexp validation (later used for mail, numbers...)

This commit is contained in:
Severin Münger
2013-09-05 22:09:08 +02:00
parent f506d9e925
commit aba394502c
4 changed files with 51 additions and 10 deletions

View File

@@ -6,16 +6,19 @@ note
class
WSF_PHONE_NUMBER_VALIDATOR
inherit
WSF_VALIDATOR[STRING]
WSF_REGEXP_VALIDATOR
create
make
make_with_message
feature -- Implementation
feature {NONE}
validate(input:STRING):BOOLEAN
do
end
make_with_message (e: STRING)
do
make_regexp_validator ("", e)
end
end

View File

@@ -0,0 +1,40 @@
note
description: "Summary description for {WSF_REGEXP_VALIDATOR}."
author: ""
date: "$Date$"
revision: "$Revision$"
class
WSF_REGEXP_VALIDATOR
inherit
WSF_VALIDATOR [STRING]
create
make_regexp_validator
feature {NONE}
make_regexp_validator (r, e: STRING)
do
make(e)
regexp_string := r
create regexp
regexp.compile (r)
end
feature -- Implementation
validate (input: STRING): BOOLEAN
do
Result := regexp.matches (input)
end
feature
regexp_string: STRING
regexp: REGULAR_EXPRESSION
end

View File

@@ -0,0 +1,25 @@
note
description: "Summary description for {WSF_VALIDATOR}."
author: ""
date: "$Date$"
revision: "$Revision$"
deferred class
WSF_VALIDATOR [G]
feature {NONE}
make (e: STRING)
do
error := e
end
feature
validate (input: G): BOOLEAN
deferred
end
error: STRING
end