themisir / form-validator

Simplest form validation for flutter form widgets
https://pub.dev/packages/form_validator
MIT License
78 stars 41 forks source link

using `required()` on an `optional` field does nothing #29

Open Fasuh opened 3 years ago

Fasuh commented 3 years ago

Describe the bug I am using global validator builder, because i want to have the same locale everywhere. bue i have noticed that whenever i am using the optional: true parameter, it overrides future required() method. i feel like it should not be an intended behaviour since the constructor of ValidationBuilder is using required()

    if (!optional) required(requiredMessage);

it should base only on that or change flag optional when we are using required()