Skip to content

Failing test for #5410#5411

Closed
rvignesh89 wants to merge 5 commits intoencode:masterfrom
rvignesh89:validator-message
Closed

Failing test for #5410#5411
rvignesh89 wants to merge 5 commits intoencode:masterfrom
rvignesh89:validator-message

Conversation

@rvignesh89
Copy link
Copy Markdown

@rvignesh89 rvignesh89 commented Sep 11, 2017

Edited by @carltongibson

Closes #5410

@lovelydinosaur
Copy link
Copy Markdown
Contributor

Thanks! Want to try implementing the fix you propose in #5410, so we can see if:

  1. That resolves the issue?
  2. If it introduces any other problems?

@rvignesh89
Copy link
Copy Markdown
Author

Do you want me to try to implement that fix?

@lovelydinosaur
Copy link
Copy Markdown
Contributor

That's up to you.
If you're up for it, then yes it'd be really helpful for moving this forward.

@rvignesh89
Copy link
Copy Markdown
Author

Sure. I'll give it a shot in the next couple of days.

@rvignesh89 rvignesh89 force-pushed the validator-message branch 2 times, most recently from a4704e8 to a0a6c3b Compare September 13, 2017 12:37
@rvignesh89
Copy link
Copy Markdown
Author

I've pushed a draft version which passes the test case that I wrote earlier. Apart from the bug fix I made a simple change in DecimalField class to simplify the creation of MinValueValidator because I noticed string formatting was being done by the BaseValidator classes.

If the changes are ok then I still need to do the following,

  1. message formatting simplification in Integer & FloatFields
  2. Check other validators for similar issues

Copy link
Copy Markdown
Contributor

@lovelydinosaur lovelydinosaur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great stuff, thanks! I've made some comments that would need addressing.

Comment thread rest_framework/utils/field_mapping.py Outdated
# rather than as a validator.
max_value = next((
validator.limit_value for validator in validator_kwarg
max_value, messsage = next((
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo in messsage here.

Comment thread rest_framework/utils/field_mapping.py Outdated
), (None, None))
if min_value is not None and isinstance(model_field, NUMERIC_FIELD_TYPES):
kwargs['min_value'] = min_value
kwargs['error_messages'] = {**kwargs['error_messages'], **{'min_value': messsage}}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't use that syntax, as it's not available in all the versions of python that we support.

Comment thread tests/test_validators.py Outdated
"""
Ensure validators can be explicitly removed..
"""

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's remove these unrelated styling changes in the pull request.

@rvignesh89
Copy link
Copy Markdown
Author

Still a WIP. Added 4 more tests for URLValidator, EmailValidator,MinLengthValidator and MaxLengthValidator. The other validators work fine.

Have to still look into the following,

  1. The MaxLengthValidator test behaves a little weird
  2. test_field_option breaks in python 2.7

@lovelydinosaur
Copy link
Copy Markdown
Contributor

The MaxLengthValidator test behaves a little weird

Specifically, what?

@carltongibson
Copy link
Copy Markdown
Collaborator

Closing in favour of #5572

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants