prots / olifer Goto Github PK
View Code? Open in Web Editor NEWLIVR implementation for Erlang
LIVR implementation for Erlang
i mean this case
my rule >>
{
"action": ["required", {"max_length":30}],
"some_obj": [{
"default":{},
"list_of_objects": {
"name": ["required",{"max_length":50}],
"value": ["required",{"max_length":300}]
}
}]
}
result should be >>
{
"action": "get",
"templateParams": {}
}
Description the rule list_of:
Allows you to describe validation rules for a list. Validation rules will be applyed for each array element.
Error code: depends on nested validators
Example:
// new syntax (introduced in v0.4)
{ product_ids: { 'list_of': 'positive_integer' }}
{ product_ids: { 'list_of': ['required', 'positive_integer'] }} // new syntax
Please fix this functionality. Best regards!
Here is an example, where i have received an error in validation
Data for validation
[{<<"id">>,<<"323232121133232">>},
{<<"src_addr">>,<<"some.link">>},
{<<"dst_addr">>,<<"+380990000000">>},
{<<"category">>,<<"qwerty">>},
{<<"message_template">>,
[[{<<"text">>,<<"some text here">>}]]}].
Rules for olifer
[{<<"id">>,
[<<"required">>,
[{<<"max_length">>,64}],
[{<<"like">>,<<"^[A-Za-z_0-9]{1,64}$">>}]]},
{<<"src_addr">>,
[<<"required">>,<<"not_empty">>,
[{<<"like">>,<<"^[A-Za-z_.0-9]{1,64}$">>}]]},
{<<"dst_addr">>,
[<<"required">>,<<"not_empty">>,
[{<<"like">>,<<"^\\+(380[0-9]{9}|[1-9][0-9]{7,14})$">>}]]},
{<<"category">>,
[<<"not_empty">>,
[{<<"max_length">>,64}],
[{<<"like">>,<<"^[A-Za-z_0-9]{1,64}$">>}]]},
{<<"message_template">>,
[<<"required">>,
[{<<"list_of_objects">>,
[{<<"text">>,[<<"not_empty">>]}]}]]}]
In version olifer 0.4.0 it returns:
{ok,[{<<"id">>,<<"323232121133232">>},
{<<"src_addr">>,<<"some.link">>},
{<<"dst_addr">>,<<"+380990000000">>},
{<<"category">>,<<"qwerty">>},
{<<"message_template">>,
[[{<<"text">>,<<"some text here">>}]]}]}
In version olifer 0.4.1 it returns an error:
{errors,[{<<"message_template">>,
[<<"Rule 'text' not_registered">>]}]}
All you need is to update your implementation to pass the latest spec's test suite.
so in 2017 was released 20.0 Erlang
maps in Erlang from 18 Erlang
why library still doesn't support maps ?
Here is the example for reproduce:
http://livr-multi-playground.webbylab.com/#%7B%22rules%22%3A%22%7B%5Cn%20%20%20%20'test'%3A%20'decimal'%5Cn%7D%22%2C%22input%22%3A%22%7B%5Cn%20%20%20%20'test'%3A%20-3.00%5Cn%7D%22%7D
I have added additional tests to test suite - koorchik/LIVR@3bfd694
Here is an example, how it was fixed in JS implementation - koorchik/js-validator-livr@5e8dc21#diff-1e3604932255b8e9b4aba0a1c5f96ae9R35
Olifer version is still 0.4.2. in olifer.app.src. This number is used by livr-multi-playground for automatic display version of used olifer.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.