toValidate method

String toValidate (
  1. {String customMessage}
)

Default error code is 401 Default variable name is $validator

Implementation

String toValidate({String customMessage}) {
  var text = """\$validator = $this;

   if (\$validator->fails()) {
          return response()->json(['response_code' => 401, 'error' => \$validator->errors(), $customMessage], 401);
      } """;
  return text;
}