Move wsf_js_widget library under draft/library/server/wsf_js_widget

This commit is contained in:
2014-07-07 10:26:10 +02:00
parent 3c8dc0a9e1
commit fe4c283336
106 changed files with 16 additions and 16 deletions

View File

@@ -0,0 +1,46 @@
note
description: "[
Wrapper whit which a agent can be used as validator
]"
author: ""
date: "$Date$"
revision: "$Revision$"
class
WSF_AGENT_VALIDATOR [G]
inherit
WSF_VALIDATOR [G]
rename
make as make_validator
end
create
make
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 -- 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

@@ -0,0 +1,30 @@
note
description: "[
Validator implementation which make sure that the input is a decimal number
]"
author: ""
date: "$Date$"
revision: "$Revision$"
class
WSF_DECIMAL_VALIDATOR
inherit
WSF_REGEXP_VALIDATOR
rename
make as make_regexp_validator
end
create
make
feature {NONE} -- Initialization
make (e: STRING_32)
-- Initialize with specified error message which will be displayed on validation failure
do
make_regexp_validator ("^[0-9]+(\.[0-9]*)?$|^\.[0-9]+$", e)
end
end

View File

@@ -0,0 +1,45 @@
note
description: "[
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 '@'.
This is a simple checker, it does not handle all the cases.
]"
EIS: "name=Application Techniques for Checking and Transformation of Names RFC3696", "protocol=URI", "src=http://tools.ietf.org/html/rfc3696#section-3"
EIS: "name=Email address (wikipedia)", "protocol=URI", "src=http://en.wikipedia.org/wiki/Email_address"
date: "$Date$"
revision: "$Revision$"
class
WSF_EMAIL_VALIDATOR
inherit
WSF_REGEXP_VALIDATOR
rename
make as make_regexp_validator
end
create
make
feature {NONE} -- Initialization
make (e: STRING_32)
-- Initialize with specified error message
do
make_regexp_validator ("^.*@.*$", e)
end
note
copyright: "2011-2014, Yassin Hassan, Severin Munger, Jocelyn Fiat, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
source: "[
Eiffel Software
5949 Hollister Ave., Goleta, CA 93117 USA
Telephone 805-685-1006, Fax 805-685-6869
Website http://www.eiffel.com
Customer support http://support.eiffel.com
]"
end

View File

@@ -0,0 +1,63 @@
note
description: "[
Validator implementation which make sure that the uploaded file is smaller than x bytes
]"
author: ""
date: "$Date$"
revision: "$Revision$"
class
WSF_FILESIZE_VALIDATOR
inherit
WSF_VALIDATOR [detachable WSF_FILE_DEFINITION]
rename
make as make_validator
redefine
state
end
create
make
feature {NONE} -- Initialization
make (m: INTEGER; e: STRING_32)
-- Initialize with specified maximum filesize and error message which will be displayed on validation failure
do
make_validator (e)
max := m
end
feature -- Implementation
is_valid (a_input: detachable WSF_FILE_DEFINITION): BOOLEAN
do
Result := a_input /= Void implies a_input.size < max
end
feature -- State
state: WSF_JSON_OBJECT
do
Result := Precursor
Result.put_integer (max, "max")
end
feature -- Access
max: INTEGER
-- The maximal allowed value
;note
copyright: "2011-2014, Yassin Hassan, Severin Munger, Jocelyn Fiat, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
source: "[
Eiffel Software
5949 Hollister Ave., Goleta, CA 93117 USA
Telephone 805-685-1006, Fax 805-685-6869
Website http://www.eiffel.com
Customer support http://support.eiffel.com
]"
end

View File

@@ -0,0 +1,63 @@
note
description: "[
Validator implementation which make sure that the input is at most x long.
]"
author: ""
date: "$Date$"
revision: "$Revision$"
class
WSF_MAX_VALIDATOR [G -> FINITE [ANY]]
inherit
WSF_VALIDATOR [G]
rename
make as make_validator
redefine
state
end
create
make
feature {NONE} -- Initialization
make (m: INTEGER; e: STRING_32)
-- Initialize with specified minimum `m' and error message `e' which will be displayed on validation failure.
do
make_validator (e)
max := m
end
feature -- Implementation
is_valid (a_input: G): BOOLEAN
do
Result := a_input.count < max or a_input.count = max
end
feature -- State
state: WSF_JSON_OBJECT
do
Result := Precursor
Result.put_integer (max, "max")
end
feature -- Properties
max: INTEGER
-- The maximal allowed value
;note
copyright: "2011-2014, Yassin Hassan, Severin Munger, Jocelyn Fiat, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
source: "[
Eiffel Software
5949 Hollister Ave., Goleta, CA 93117 USA
Telephone 805-685-1006, Fax 805-685-6869
Website http://www.eiffel.com
Customer support http://support.eiffel.com
]"
end

View File

@@ -0,0 +1,53 @@
note
description: "[
Validator implementation which make sure that the input is at least x long.
]"
author: ""
date: "$Date$"
revision: "$Revision$"
class
WSF_MIN_VALIDATOR [G -> FINITE [ANY]]
inherit
WSF_VALIDATOR [G]
rename
make as make_validator
redefine
state
end
create
make
feature {NONE} -- Initialization
make (m: INTEGER; e: STRING_32)
-- Initialize with specified minimum and error message which will be displayed on validation failure
do
make_validator (e)
min := m
end
feature -- Implementation
is_valid (input: G): BOOLEAN
do
Result := input.count > min or input.count = min
end
feature -- State
state: WSF_JSON_OBJECT
do
Result := Precursor
Result.put_integer (min, "min")
end
feature -- Properties
min: INTEGER
-- The minimal allowed value
end

View File

@@ -0,0 +1,64 @@
note
description: "[
Validator implementation which validates the input based on a given regular expression
]"
author: ""
date: "$Date$"
revision: "$Revision$"
class
WSF_REGEXP_VALIDATOR
inherit
WSF_VALIDATOR [STRING_32]
rename
make as make_validator
redefine
state
end
create
make
feature {NONE} -- Initialization
make (r, e: STRING_32)
-- Initialize with specified regular expression and error message which will be displayed on validation failure
do
make_validator (e)
regexp_string := r
create regexp
ensure regexp_string_set: regexp_string = r
end
feature -- Implementation
is_valid (input: STRING_32): BOOLEAN
do
--Only compile when used
if not regexp.is_compiled then
regexp.compile (regexp_string)
end
Result := (not input.is_empty) and regexp.matches (input)
end
feature -- State
state: WSF_JSON_OBJECT
do
create Result.make
Result.put_string ("WSF_REGEXP_VALIDATOR", "name")
Result.put_string (regexp_string, "expression")
Result.put_string (error, "error")
end
feature -- Properties
regexp_string: STRING_32
-- The regexp in string representation
regexp: REGULAR_EXPRESSION
-- The regexp of this validator
end

View File

@@ -0,0 +1,24 @@
note
description: "[
Defines that control can be validated.
]"
author: ""
date: "$Date$"
revision: "$Revision$"
deferred class
WSF_VALIDATABLE
feature -- Specification
validate
-- Perform validation
deferred
end
is_valid: BOOLEAN
-- Result of last validation
deferred
end
end

View File

@@ -0,0 +1,53 @@
note
description: "[
Base validation class which can be added to the WSF_FORM_ELEMENT_CONTROL
]"
author: ""
date: "$Date$"
revision: "$Revision$"
deferred class
WSF_VALIDATOR [G]
feature {NONE} -- Initialization
make (e: STRING_32)
-- Initialize with specified error message `e' to be displayed on validation failure.
do
error := e
ensure
error_set: error = e
end
feature -- Access
state: WSF_JSON_OBJECT
-- JSON state of this validator
do
create Result.make
Result.put_string (generator, "name")
Result.put_string (error, "error")
-- FIXME: is that correct to always send error message??
end
is_valid (a_input: G): BOOLEAN
-- Perform validation on given input and tell whether validation was successful or not
deferred
end
feature -- Properties
error: STRING_32
-- The error message if validation fails.
;note
copyright: "2011-2014, Yassin Hassan, Severin Munger, Jocelyn Fiat, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
source: "[
Eiffel Software
5949 Hollister Ave., Goleta, CA 93117 USA
Telephone 805-685-1006, Fax 805-685-6869
Website http://www.eiffel.com
Customer support http://support.eiffel.com
]"
end