Min/Max validator
This commit is contained in:
@@ -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
|
||||
@@ -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
|
||||
@@ -38,6 +38,7 @@ feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- STATE MANAGEMENT
|
||||
do
|
||||
create Result.make
|
||||
Result.put (create {JSON_BOOLEAN}.make_boolean (checked), create {JSON_STRING}.make_json ("checked"))
|
||||
Result.put (create {JSON_STRING}.make_json (checked_value), create {JSON_STRING}.make_json ("checked_value"))
|
||||
Result.put (create {JSON_BOOLEAN}.make_boolean (attached change_event), create {JSON_STRING}.make_json ("callback_change"))
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user