Apisix-dashboard: feat: Improve the regexp, reference some standard projects

Created on 22 Mar 2021  路  5Comments  路  Source: apache/apisix-dashboard

Now, we use jsonschema to verfiy the fields of objects.

As @juzhiyuan suggested, Need to modify regexp refer to some standard projects .

For example, verify fields such as name, password, email. This can avoid some mistakes.

discuss enhancement help wanted

All 5 comments

Hi, guys.

Are there any good reference projects? Please list them here. I have searched many projects on github.
But there are no standard, only different needs.

There are some regular libraries, but the regular expressions still need to be filled in by yourself.

Hello, please have this issue tagged :)

ya, here have some examples: https://projects.lukehaas.me/regexhub/

and @LiteSun, could you help to provide some rules from antd?

Great~ but I think https://projects.lukehaas.me/regexhub/ is not enough.

Maybe regex does have some standards or best practices, but meeting our needs is the most important thing.
We can only refer to the examples you give.

For example, we need regex-expr for ipv4 and domain, but it is only ipv4.

// now what we use
(^([1-9]?\d|1\d{2}|2[0-4]\d|25[0-5])(\.(25[0-5]|1\d{2}|2[0-4]\d|[1-9]?\d)){3}$|^(?![0-9.]+$)([a-zA-Z0-9_-]+)(\.[a-zA-Z0-9_-]+){0,}$)
// which is in lukehaas.me
/^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/



md5-2b0dd3f921934fa43e750359e17a3f50



// now what we use is better
^[a-zA-Z\u4e00-\u9fa5][a-zA-Z0-9\u4e00-\u9fa5_-]{1,100}$

ya, here have some examples: https://projects.lukehaas.me/regexhub/

and @LiteSun, could you help to provide some rules from antd?

ANTD uses the async-validator library for field checking, if you want to see the regular rules you need to look through the source code, which is not very convenient

Was this page helpful?
0 / 5 - 0 ratings