Git Product home page Git Product logo

kanone's People

Contributors

doncatnip avatar sergio-bershadsky avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

kanone's Issues

rework tagging

When #14 is done, tagging needs to be reworked as right now nested tag parameters work as follows:
o = MyComposedValidator(taggedValidator_validationParameter=42)

with under_score naming this would not be possible.

Add gettext to messages

Example:

before

@messages\
    ( type="Invalid type (%(value.type)s), must be a integer"
    , convert="Could not convert %(value.type)s to integer"
    )

after

from gettext import gettext as _

@messages\
    ( type=_("Invalid type (%(value.type)s), must be a integer")
    , convert=_("Could not convert %(value.type)s to integer")
    )

Strange naming in Match validator

I'found that Match validator seems to be copy pasted ? Am I right ?

...
def setParameters(self, required, ignoreCase=False):
...

"required" adds misunderstand in validator uses, maybe it will be better to change to something more meaningful ? like expression, pattern or s.e.

Correct message

/kanone/validator/check.py
from:
max="Value cannot have more than least%(max)i elements/characters (has %(len)s)"

to:
max="Value cannot have more than least %(max)i elements/characters (has %(len)s)"

missing space between "least %(max)i"

camelCase to under_score

Refactor kanone to use under_score instead of camelCase for variables, parameters and function names

An idea, using convert for Boolean

@messages\
  ( type="Invalid type (%(value.type)s), must be a bool"
)
class HumanBoolean( TypeValidator):

  def on_value(self, context, value):
    if isinstance(value, int )\
    and not(value<0 or value>1):
      value = bool(value)

    if not (isinstance( value, bool )):
      if self._convert:
        if str(value).lower() in ('1', 'true', 'yes', 'on'):
          return True
        elif str(value).lower() in ('0', 'false', 'no', 'off'):
          return False
      raise Invalid( value, self, 'type' )
    return value

Unicode problem when using Len validator

the code

s2 = (
  't1', String() & Len(max=9),
)

s = Schema(
  *s2
)

c2 = {
  't1': u'Скушай яблоко',
}

c = s.context(c2)

Traceback (most recent call last):
File "utils.py", line 94, in
result = c.result
File "build/bdist.linux-x86_64/egg/kanone/lib.py", line 222, in result
return self.validate()
File "build/bdist.linux-x86_64/egg/kanone/lib.py", line 331, in validate
result = self.validator.validate( self, self.value)
File "build/bdist.linux-x86_64/egg/kanone/validator/core.py", line 116, in validate
return self.on_value( context, value )
File "build/bdist.linux-x86_64/egg/kanone/validator/schema.py", line 69, in on_value
return self.on_value( context, value )
File "build/bdist.linux-x86_64/egg/kanone/validator/schema.py", line 174, in _createContextChilds_on_value
res = context( key ).result
File "build/bdist.linux-x86_64/egg/kanone/lib.py", line 222, in result
return self.validate()
File "build/bdist.linux-x86_64/egg/kanone/lib.py", line 334, in validate
self.error = e
File "build/bdist.linux-x86_64/egg/kanone/lib.py", line 250, in error
extra['value'] = str(value)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-5: ordinal not in range(128)

evaluate if Blank should be dropped

since Blank is restricted to the String datatype only maybe on_blank should not be a thing - and if we want to keep it, a string containing whitespaces should count as blank too.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.