Min/Max validator

This commit is contained in:
YNH Webdev
2013-09-06 21:47:02 +02:00
parent 133ed9a0be
commit 8b179fd98d
6 changed files with 224 additions and 5 deletions

View File

@@ -0,0 +1,45 @@
note
description: "Summary description for {WSF_MAX_VALIDATOR}."
author: ""
date: "$Date$"
revision: "$Revision$"
class
WSF_max_VALIDATOR[G]
inherit
WSF_VALIDATOR [LIST[G]]
redefine
state
end
create
make_max_validator
feature {NONE}
make_max_validator (m:INTEGER; e: STRING)
do
make (e)
max := m
end
feature -- Implementation
is_valid (input:LIST[G]): BOOLEAN
do
Result:= input.count < max or input.count = max
end
feature
state: JSON_OBJECT
do
Result := Precursor
Result.put (create {JSON_NUMBER}.make_integer (max), create {JSON_STRING}.make_json ("max"))
end
max: INTEGER
end

View File

@@ -0,0 +1,45 @@
note
description: "Summary description for {WSF_MIN_VALIDATOR}."
author: ""
date: "$Date$"
revision: "$Revision$"
class
WSF_MIN_VALIDATOR[G]
inherit
WSF_VALIDATOR [LIST[G]]
redefine
state
end
create
make_min_validator
feature {NONE}
make_min_validator (m:INTEGER; e: STRING)
do
make (e)
min := m
end
feature -- Implementation
is_valid (input:LIST[G]): BOOLEAN
do
Result:= input.count > min or input.count = min
end
feature
state: JSON_OBJECT
do
Result := Precursor
Result.put (create {JSON_NUMBER}.make_integer (min), create {JSON_STRING}.make_json ("min"))
end
min: INTEGER
end