emmett-framework / emmett

The web framework for inventors
BSD 3-Clause "New" or "Revised" License
1.06k stars 71 forks source link

Possible bug with custom message validators #286

Closed josejachuf closed 4 years ago

josejachuf commented 4 years ago

Hi @gi0baro I think this is a possible bug. Using validators, if for a field I create: 'myfield': {'presence': True, message: 'my custom message'},

this doesn't work, it always shows "Cannot be empty" however it works fine for the other validators for example: {'is': 'email', message: 'my custom message'} or {'len': {'gt: 10}, message:' my custom message '}

I'm using it on weppy 1.3.4, didn't test it on emmett

Jose

gi0baro commented 4 years ago

@josejachuf I confirm this is a bug in both 1.x and 2.x. Messages gets configured too early in the process: https://github.com/emmett-framework/emmett/blob/master/emmett/validators/__init__.py#L225

This will need some refactoring, probably require some time to fix.