|Last Updated||Ratings||Unique User Downloads||Download Rankings|
|2019-06-13 (5 months ago)||Not yet rated by the users||Total: 95||All time: 9,306 This week: 313|
|validationone 1.0||GNU Lesser Genera...||5||HTTP, PHP 5, Validation|
This package can fetch and validate forms and request values.
It's a PHP library for fetch and validate fields and store messages in different containers(including error, warning, info, and success) depending on the conditions.
It is an example of functionality. A normal example is more complex, even if it's only a few lines of code.
Let's say we want to validate a value an input value (get) called "id", we could do the next things:
$val=new ValidationOne(); $r = $val->def('ERROR') ->type('integer') ->condition("eq", "It's not equals to 10", 10) ->condition("eq", "It's not equals to 30 (info)", 30, 'info') ->ifFailThenDefault() ->get('id'); // <-- end of the chain
But, where is the error?. It's in messagelist
var_dump($val->messagelist->allArray()) // here we show all messages of any kind of type.
However, we could also show a message by type (error, warning..) and only message by specific identifier.
var_dump($val->messageList->get('id')->allErrorOrWarning())) // All error or warning contained in the key "id".
Why the messages are store in some structure?. Is it not easy to simply return the error? .
The answer is a form. Le't say we have a form with 3 fields. If one of them fails, then the error must be visible for each field separately. Also the whole form could have it's own message.
@param string $type
number:req,eq,ne,gt,lt,gte,lte,between string:req,eq,ne,minlen,maxlen,betweenlen,notnull date:req,eq,ne,gt,lt,gte,lte,between> boolean:req,eq,ne,true,false function: fn.static.Class.methodstatic fn.global.function fn.object.Class.method where object is a global $object fn.class.Class.method fn.class.\namespace\Class.method
@param string $message
Message could uses the next variables '%field','%realfield','%value','%comp','%first','%second'
MessageList is a list of containers of messages. It's aimed for convenience, so it features many methods to access of the information in different ways.
Messages are cataloged as follow
| id | Description | Example | |---------|----------------------------------------------------------------------|---------------------------------------| | error | The message is an error and it must be solved. It is a show stopper. | Database is down | | warning | The message is a warning that maybe it could be ignored. | The registry was stored but with warnings | | info | The message is an information | Log is stored | | success | The message is a succesful operation | Order Accepted | |
Sometimes, both errors are warning are considered as equals. So the system allows to read an error or warning.
Error has always the priority, then warning, info and success. If you want to read the first message, then it starts searching for errors.
You can obtain a message as an array of objects of the type MessageItem, as an array of string, or as an a single string (first message)
It's distributed as dual license, as lgpl-v3 and commercial.
You can use freely in your close source project. However, if you change this library, then the changes must be disclosed.
|docs (1 file)|
|Version Control||Unique User Downloads||Download Rankings|