@param Asker $asker
@param       $modelName
@param       $oldName
@param       $newName
@param Field $fieldObj

@return ConfirmationQuestion

@since  1.1.0

@author Eddilbert Macharia (http://eddmash.com) <edd.cowan@gmail.com>
3839
public static function hasFieldRenamed(Asker $asker, $modelName, $oldName, $newName, Field $fieldObj)
    {
        $msg = 'Did you rename %1$s.%2$s to %1$s.%3$s (a %4$s)? [y/N]';

        $q = new ConfirmationQuestion(sprintf($msg, $modelName, $oldName, $newName, $fieldObj->getShortClassName()));

        return $asker->ask($q);
    }
718092
protected function _allowEmpty(Model $model, $field, $value) {
        if (isset($this->_validations[$field]['required'])) {
            $rule = $this->_validations[$field]['required'];
            $required = isset($rule['rule'][1]) ? $rule['rule'][1] : true;

            if ($this->_isEmpty($value)) {
                if ($rule['allowEmpty']) {
                    return true;

                } else if ($required) {
                    return false;
                }
            }
        }

        return false;
    }
454559
private function askConfirmation(InputInterface $input, OutputInterface $output, $question, $default)
    {
        /** @var QuestionHelper $questionHelper */
        $questionHelper = $this->getHelperSet()->get('question');
        $question = new ConfirmationQuestion($question, $default);

        return (bool) $questionHelper->ask($input, $output, $question);
    }
331940
protected function askConfirmation($question, InputInterface $input, OutputInterface $output) {
        if (!$this->getHelperSet()->has('question')) {
            return $this->getHelper('dialog')
                ->askConfirmation($output, '<question>' . $question . '</question>', 'y');
        }

        return $this->getHelper('question')
            ->ask($input, $output, new \Symfony\Component\Console\Question\ConfirmationQuestion($question));
    }
1010709
protected function getConfirmationQuestion(string $questionName, bool $defaultValue = false): ConfirmationQuestion
    {
        return new ConfirmationQuestion(
            sprintf(
                '<info>%s</info> [<comment>%s</comment>]? ',
                $questionName,
                $defaultValue ? 'yes' : 'no'
            ),
            $defaultValue
        );
    }
667083
public function fieldIsRequired($fieldName)
    {
        if ($rules = $this->getRulesForFieldName($fieldName)) {
            
            foreach ($rules as $rule) {
                
                if ($rule instanceof RequiredRule) {
                    return true;
                }
                
            }
            
        }
        
        return parent::fieldIsRequired($fieldName);
    }
1370801
private function askForFieldName(InputInterface $input, OutputInterface $output, QuestionHelper $dialog, $fields)
    {
        $question = new Question($dialog->getQuestion('New field name (press <return> to stop adding fields)', null));
        $question->setValidator(function ($name) use ($fields) {
            if (isset($fields[$name]) || 'id' == $name) {
                throw new \InvalidArgumentException(sprintf('Field "%s" is already defined.', $name));
            }

            return $name;
        });

        return $dialog->ask($input, $output, $question);
    }
963101
public static function changePasswordByCode($email, $code, $newPassword, $login = true)
    {
        if (empty($email)) {
            throw new BadRequestException("Missing required email for password reset confirmation.");
        }

        if (empty($newPassword)) {
            throw new BadRequestException("Missing new password for reset.");
        }

        if (empty($code) || 'y' == $code) {
            throw new BadRequestException("Invalid confirmation code.");
        }

        /** @var User $user */
        $user = User::whereEmail($email)->whereConfirmCode($code)->first();

        if (null === $user) {
            // bad code
            throw new NotFoundException("The supplied email and/or confirmation code were not found in the system.");
        } elseif ($user->isConfirmationExpired()) {
            throw new BadRequestException("Confirmation code expired.");
        }

        static::isAllowed($user);

        try {
            $user->confirm_code = 'y';
            $user->password = $newPassword;
            $user->save();
        } catch (\Exception $ex) {
            throw new InternalServerErrorException("Error processing password reset.\n{$ex->getMessage()}");
        }

        if ($login) {
            static::userLogin($email, $newPassword);

            return ['success' => true, 'session_token' => Session::getSessionToken()];
        }

        return ['success' => true];
    }
266627
public function renameCheck($oldName, $newName)
    {
        if (!$this->hasCheck($oldName)) {
            throw SchemaException::tableCheckDoesNotExist($this->getName(), $oldName);
        }

        if ($this->hasCheck($newName)) {
            throw SchemaException::tableCheckAlreadyExists($this->getName(), $newName);
        }

        $this->checks[$oldName]->setName($newName);
        $this->checks[$newName] = $this->checks[$oldName];
        unset($this->checks[$oldName]);
    }
163937
public function askInput($questionText, $default = null, array $autoCompleterValues = [], callable $validator = null)
    {
        if ($default !== null) {
            $questionText .= ' <question>[' . $default . ']</question>';
        }
        $questionText .= ': ';
        $question = new Question($questionText, $default);
        if (!empty($autoCompleterValues)) {
            $question->setAutocompleterValues($autoCompleterValues);
        }
        if ($validator !== null) {
            $question->setValidator($validator);
            $question->setMaxAttempts(5);
        }

        return $this->ask($this->input, $this->output, $question);
    }
1218879
protected function createRequest(Question $question): Message
    {
        $request = $this->messageFactory->create(MessageTypes::QUERY);
        $request->getQuestionRecords()->add($question);
        $request->isRecursionDesired(true);

        $request->setID($this->createId());

        return $request;
    }
220086
public function renameTable($oldName, $newName)
    {
        if (!$this->hasTable($oldName)) {
            throw SchemaException::schemaTableDoesNotExist($this->getName(), $oldName);
        }

        if ($this->hasTable($newName)) {
            throw SchemaException::schemaTableAlreadyExists($this->getName(), $newName);
        }

        $this->tables[$oldName]->setName($newName);
        $this->tables[$newName] = $this->tables[$oldName];

        unset($this->tables[$oldName]);
    }
69940
protected function _checkFieldType($modelFieldName = null) {
		if (empty($modelFieldName) || !is_string($modelFieldName)) {
			return false;
		}

		if (strpos($modelFieldName, '.') === false) {
			return false;
		}

		list($modelName, $fieldName) = pluginSplit($modelFieldName);
		$schema = $this->_getSchemaForModel($modelName);
		if (($schema === null) || !is_array($schema) || !isset($schema[$fieldName]['type']) ||
			!in_array($schema[$fieldName]['type'], ['text', 'string'])) {
			return false;
		}

		return true;
	}
929722
public function rename($oldname, $newname) {
		$this->connectIfNeeded();
		$this->handle->rename($oldname, $newname);
		$this->onFileRenamed(
			new Event(['sender' => $this, 'data' => [
				'oldname' => $oldname, 
				'newname' => $newname
			]])
		);
	}
841237
private static function getDefault(Asker $asker)
    {
        $default_val = '';
        $msg = PHP_EOL.'Please enter the default value now, ensure its a valid PHP '.PHP_EOL.' >>> ';
        while (true) {
            $default = $asker->ask(new Question($msg));
            if (empty($default)) {
                $msg = " Please enter some value, or 'exit' (with no quotes) to exit.".PHP_EOL;
            } elseif ('exit' == $default) {
                break;
            } elseif (false === $default) {
                Console::error(PHP_EOL.' An error occured while trying to set default value');

                break;
            } else {
                $default_val = $default;

                break;
            }
        }

        return $default_val;
    }
321415
public function handle($old, $new)
    {
        if ( ! $this->canHandle($old) || ! $this->canHandle($new)) {
            return null;
        }

        if ($this->equals($old, $new)) {
            return false;
        }

        $this->lastException = new FailedConstraint(
            sprintf(
                '%s() body changed',
                $new->name
            )
        );

        return true;
    }
926442
public function fieldGreaterThanAnother(string $fieldName, string $otherFieldName)
    {
        $this->validateFieldsExist(__METHOD__, $fieldName, $otherFieldName);

        return $this->validate(new FieldGreaterThanAnotherValidator($this->fields[$fieldName], $this->fields[$otherFieldName]));
    }