#351 The Github widget's data validators aren't implemented
Closed: Fixed 4 years ago Opened 4 years ago by abompard.

The validators used by the Github widget aren't implemented. See:

  • hubs.widgets.validators.GithubOrganization
  • hubs.widgets.validators.GithubRepo

Metadata Update from @abompard:
- Issue priority set to: High
- Issue tagged with: flock

4 years ago

Metadata Update from @sayanchowdhury:
- Issue priority set to: Low (was: High)
- Issue tagged with: easyfix, enhancement

4 years ago

I'm working on this issue and there are several things I want to clarify.
I managed to implement GithubOrganization validator, but GithubRepo validator receives only name of repository as an argument without owner's name. Looking at the file utils/views.py where validation is actually called - one possible solution to validate this widget's form exclusively. That way I will be able to pass both username and reponame as an argument to GithubRepo validator. I'm open to any suggestions on how to handle this.

P.S. I am a newbie, don't judge me to harsh :)

It's true that the validation infrastructure is currently not smart enough to give you the information you need to validate the field. I can see several ways of doing this in a cleanish way, but the simplest I can think of would be to have a new method on the Widget class called validate_parameters() that would accept the whole parameters dict and would call the validators for each field, return the validated values or raise ValueError.
This method could be called in utils.views as you said.
Then it would be possible to override this method for the widgets that need it and do additional checks with multiple fields at the same time.

What do you think?

It's true that the validation infrastructure is currently not smart enough to give you the information you need to validate the field. I can see several ways of doing this in a cleanish way, but the simplest I can think of would be to have a new method on the Widget class called validate_parameters() that would accept the whole parameters dict and would call the validators for each field, return the validated values or raise ValueError.
This method could be called in utils.views as you said.
Then it would be possible to override this method for the widgets that need it and do additional checks with multiple fields at the same time.
What do you think?

Yeah, this sounds cleaner than what I've suggested. I'll implement it.

Is there anything else you think I should take into account?

Metadata Update from @abompard:
- Issue assigned to anar
- Issue close_status updated to: Fixed
- Issue status updated to: Closed (was: Open)

4 years ago

Login to comment on this ticket.

Metadata