encodeMaxLengthEnforcement static method

String? encodeMaxLengthEnforcement(
  1. MaxLengthEnforcement? value, {
  2. bool validate = true,
})

Encodes the value to a MaxLengthEnforcement. Supported values are:

  • enforced
  • none
  • truncateAfterCompositionEnds

Implementation

static String? encodeMaxLengthEnforcement(
  MaxLengthEnforcement? value, {
  bool validate = true,
}) {
  String? result;
  if (value != null) {
    switch (value) {
      case MaxLengthEnforcement.enforced:
        result = 'enforced';
        break;
      case MaxLengthEnforcement.none:
        result = 'none';
        break;
      case MaxLengthEnforcement.truncateAfterCompositionEnds:
        result = 'truncateAfterCompositionEnds';
        break;
    }
  }

  return result;
}