joanpablo / reactive_forms

This is a model-driven approach to handling form inputs and validations, heavily inspired in Angular's Reactive Forms
MIT License
472 stars 90 forks source link

`allowNull` flag for number validator #451

Closed vasilich6107 closed 6 months ago

vasilich6107 commented 7 months ago

Connection with issue(s)

Close https://github.com/joanpablo/reactive_forms/issues/450

Solution description

Allow null values for number validator to increase flexibility

To Do

codecov[bot] commented 7 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 95.02%. Comparing base (839968f) to head (0201a39).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #451 +/- ## ======================================= Coverage 95.01% 95.02% ======================================= Files 67 67 Lines 1385 1386 +1 ======================================= + Hits 1316 1317 +1 Misses 69 69 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

vasilich6107 commented 7 months ago

Hi @joanpablo could you review this tiny improvement

joanpablo commented 6 months ago

Hi @vasilich6107

Would you mind to elaborate on this PR. Why would you need a Validator if the value can be nullable? Can you show me an example for this use case?

vasilich6107 commented 6 months ago

Hi, thanks for merging and sorry for delayed response.

The example is really simple.

If we take a user profile from with variety of data there could be some fields like height and weight. Which could be optional to fill but if user fills them it would be nice to validate that entered data is a number.

Technically we could utilize different controls for those cases but if we a rapidly prototyping the form it would be much easier to copy paste the the test field from (the same as was used for FirstName) and change the validator