Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QSTN: JsonParam int validation #83

Closed
choonyme opened this issue Jul 5, 2023 · 6 comments
Closed

QSTN: JsonParam int validation #83

choonyme opened this issue Jul 5, 2023 · 6 comments

Comments

@choonyme
Copy link

choonyme commented Jul 5, 2023

Is there a way to validate an int property with JsonParam? So far I can only pass in CompositeRules but nothing other than that.
For example,

@validate_params(
JsonParam({
'namespace': [int],
'key': [MinLength(1), MaxLength(255)],
'value': [MaxLength(255)] }, required=True, as_list=True)
)

This 'namespace' type would result in an error. Let me know if there's a way to achieve this. Thanks.

@d-ganchar
Copy link
Owner

@choonyme Hello 👋
Thank you for your question. I'll let you know next week

@d-ganchar
Copy link
Owner

@choonyme could you show the data structure please?

@choonyme
Copy link
Author

@choonyme could you show the data structure please?

It's
[
{
"namespace": "test1", <---- how to verify this as string?
"key": "test1key",
"value": "test1value',
},
{
"namespace": "test2",
"key": "test2key",
"value": "test2value',
},
]

@d-ganchar
Copy link
Owner

@choonyme I need to think. Looks like some rules need to be added(IntRule, FloatRule, BoolRule).
It would also be nice to convert a string to the required type:

"1" -> True
"true" -> True
"10.235" -> 10.235(float)
etc

@d-ganchar d-ganchar added this to the 4.3.0 milestone Aug 24, 2023
d-ganchar added a commit that referenced this issue Nov 17, 2023
d-ganchar added a commit that referenced this issue Dec 12, 2023
@d-ganchar
Copy link
Owner

@choonyme published. I'll update docs later. I'm really very busy

@d-ganchar d-ganchar added the doc label Dec 12, 2023
@d-ganchar
Copy link
Owner

rules
release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants