value property

String? value

CNPJ as a digit-only value — non-numeric characters are stripped from it.

There are three scenarios for a CNPJ value. If it is:

  1. properly masked as '##.###.###/####-##', then the dots ".", slash "/", and dash "-" will be stripped from it (e.g., '13.497.166/0001-07' becomes '13497166000107').
  2. composed entirely of 14 numbers, then it will remain unchanged (e.g.,'41831918000160' remains as is).
  3. malformed, then the null value will be returned to indicate a formatting error. (e.g., the values '111AB222333445' and '40.769-9110/001.00' become null).

Implementation

String? get value => _isWellFormed ? _strip : null;