-
Notifications
You must be signed in to change notification settings - Fork 6
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
Feature: implement new validators #139
Feature: implement new validators #139
Conversation
We are getting this error when running ncbo/ontologies_linked_data unit tests:
Is there another pull request inside ontologies_linked_data that we are missing? |
With the new validators in place, it appears that the "username" of the User object is automatically assumed to have been loaded, which is not always the case, hence these errors. This errors out in multiple places in our test code. |
These types of errors would be almost impossible to detect unit after the code is merged and deployed. We should be more diligent about submitting pull requests that are not fully self contained (or at least without having the additional dependencies clearly documented in the PR). |
@syphax-bouazzouni, just wanted to check if you saw my original error report. The code errors out at:
Adding this code fixes many of these errors, but not all:
Do you have a different fix to this? This issue prevents us from proceeding. |
Hi @mdorf , I just did this PR, that fixed the failing test in ontologies-linked-data (https://github.com/ontoportal-lirmm/ontologies_linked_data/actions/runs/6042678133), sorry I fixed this locally but forgot to do a PR for NCBO. A better solution (i think) would be also to update the function def empty_to_s?(object)
begin
object && object.to_s&.strip.empty?
rescue
return true
end
end |
Prerequisites
Context
See agroportal/project-management#393
Changes
Now we can call, model-specific validators.
For example, if a model defines an instance method called
equal_to_10
that tests if a value is equal to10
.Then we can reference it as a validator for an attribute, like so
attribute :age, enforce: [:equal_to_10]
, this will enforce the attributeage
to be10
(as implemented in the methodequal_to_10
)distinct_of
validator (0be7925)superior_equla_to
validator (deed329)Add
email
validator , that enforce the string to be a valid emailAdd
symmetric
validator (5164723)inverse_of
validator (d57a719)