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

Feature validators #1

Open
wants to merge 10 commits into
base: 0.75
Choose a base branch
from
Open

Feature validators #1

wants to merge 10 commits into from

Conversation

staverne
Copy link
Owner

No description provided.

@staverne staverne changed the base branch from master to 0.75 November 25, 2016 12:06
staverne added a commit that referenced this pull request Dec 1, 2016
Fix ipkg-update-locale.py after pip compliance update
class BaseValidator(validator_prototype):

validator_id = None
errors = {'invalid': MSG(u'Enter a valid value')}

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')

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.')}

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.')}

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.')}

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."),

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."),

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')

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')

Choose a reason for hiding this comment

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

invalid form values

@@ -168,6 +172,7 @@ def get_schema(self, resource, context):
return self.schema


form_error_message = ERROR(u'There are errors, check below')

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.

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.

2 participants