-
Notifications
You must be signed in to change notification settings - Fork 0
Feature validators #1
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
base: 0.75
Are you sure you want to change the base?
Conversation
da80b28 to
5cf8f39
Compare
5cf8f39 to
85403a0
Compare
Fix ipkg-update-locale.py after pip compliance update
| class BaseValidator(validator_prototype): | ||
|
|
||
| validator_id = None | ||
| errors = {'invalid': MSG(u'Enter a valid value')} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
invalid value
|
|
||
|
|
||
| def check(self, value): | ||
| raise NotImplementedError('Validator is not configured') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Validor must implement the check method
|
|
||
| validator_id = 'hexadecimal' | ||
| regex = '^#[A-Fa-f0-9]+$' | ||
| errors = {'invalid': MSG(u'Enter a valid value.')} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
invalid value
| class PositiveIntegerValidator(BaseValidator): | ||
|
|
||
| validator_id = 'integer-positive' | ||
| errors = {'integer_positive': MSG(u'Ensure this value is positive.')} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The value must be a positive integer
| class PositiveIntegerValidator(BaseValidator): | ||
|
|
||
| validator_id = 'integer-positive' | ||
| errors = {'integer_positive': MSG(u'Ensure this value is positive.')} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
C'est bizarre de définir des messages d'erreur différents à chaque fois alors que tu check juste si c'est valide ou non
| errors = { | ||
| 'too_short': MSG(u"This password is too short. It must contain at least {min_length} characters."), | ||
| 'need_character': MSG(u"This password should contains at least one character."), | ||
| 'need_number': MSG(u"This password should contains at least one number."), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Password must contain at least one number
| 'too_short': MSG(u"This password is too short. It must contain at least {min_length} characters."), | ||
| 'need_character': MSG(u"This password should contains at least one character."), | ||
| 'need_number': MSG(u"This password should contains at least one number."), | ||
| 'need_special_character': MSG(u"This password should contains at least one special character."), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Password must contain at least one special character (=,+,-,_,$,...)
| elif self.msg: | ||
| messages = [self.msg] | ||
| else: | ||
| messages = MSG(u'There are errors... XXX') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
enleve le XXX
| else: | ||
| unknow.append(name) | ||
| if missings or invalids or unknow: | ||
| error_msg = error_msg or ERROR(u'Form values are invalid') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
invalid form values
| return self.schema | ||
|
|
||
|
|
||
| form_error_message = ERROR(u'There are errors, check below') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One error occurred, check bellow.
No description provided.