Verify if a required value is set.
@param bool $yes  If true, a non-null value is required

@return Validator|Validator
979295
public function required($yes=false)
    {
        return $yes ? $this->markErrorIf($this->value===null, false) : $this;
    }
371124
def validate_boolean_or_string(option, value):
    """"""
    if isinstance(value, string_type):
        if value not in ('true', 'false'):
            raise ValueError("The value of %s must be "
                             "'true' or 'false'" % (option,))
        return value == 'true'
    return validate_boolean(option, value)
654539
function $true(params) {
    if (typeof params === 'boolean') {
        return params;
    }
    if (typeof params === 'number') {
        return params === 1;
    }
    if (typeof params === 'string') {
        params = params.trim();

        return params.toLowerCase() === 'true' || params === '1';
    }

    return false;
}
1075043
def certify_bool(value, required=True):
    
    if certify_required(
        value=value,
        required=required,
    ):
        return

    if not isinstance(value, bool):
        raise CertifierTypeError(
            message="expected bool, but value is of type {cls!r}".format(
                cls=value.__class__.__name__),
            value=value,
            required=required,
        )
1226618
public function hasRequiredSettings(bool $refresh = false): bool
    {
        $required = $this->getParsedRequiredProperties($refresh);

        if (!$this->allRequired && (empty($required) || $required === null)) {
            return true;
        }

        return $this->validateProperties($required);
    }
986480
public function validation($instance = true)
	{
		if ($instance instanceof Validation)
		{
			$this->validation = $instance;
			return $instance;
		}

		if (empty($this->validation) and $instance === true)
		{
			$this->validation = \Validation::forge($this);
		}

		return $this->validation;
	}
64681
public function valid(array $values, $populate = true)
    {
        foreach($this->getElements() as $index => &$element) {
            if(!array_key_exists($index, $values)) {
                if(is_a($element, 'FrenchFrogs\Form\Element\Boolean')){
                    $values[$index] = 0;
                } else {
                    $values[$index] = '';
                }
            }

            $element->valid($values[$index]);

            if (!$element->isValid()) {
                $this->getValidator()->addError($index, $element->getErrorAsString());
            }

        }

        return $this;
    }
1033888
public function rule_true($a)
    {
        // Changes PHP true to 1
        $a = strtolower($a);

        $vals = array('true', 't', 1, 'yes', 'y');

        if (!in_array($a, $vals)) {
            return $this->fail('Must be true');
        }
    }
588690
public function validate($value)
    {
        $this->pushResult();
        if ($this->acceptsEmptyValues === false || $this->isEmpty($value) === false) {
            $this->isValid($value);
        }
        return $this->popResult();
    }
856638
public static function boolean($value, $options = null)
    {
        if (!is_null($options)) {
            $options = explode('|', $options);
        }

        if (sizeof($options) != 2) {
            $options = array('No', 'Yes');
        }

        return $options[!!$value];
    }
138297
public function convertToBool($answer)
    {
        if (!$this->caseSensitive) {
            $answer = strtoupper($answer);
        }

        // If it equals confirm yes
        if ($answer == $this->confirmYes) {
            return true;
        }

        if ($answer == $this->confirmNo || $this->explicit === false) {
            return false;
        }

        $this->output->writeln($this->invalidConfirmationError);
    }
695181
public static function booleanValue($s)
    {
        if (is_bool($s)) {
            return $s; // it's already boolean (not a string)
        }
        // otherwise assume it's something like "true" or "t"
        $trimmed = strtolower(trim($s));

        return (boolean) in_array($trimmed, self::$TRUE_VALUES);
    }
34148
public function asBool()
    {
        if ($this->value->isNull()) {
            return null;
        }

        return $this->value->isOneOf([1, '1', 'true', true, 'yes'], true);
    }
623383
final protected function checkBooleanResponse(string $res):int
    {
        if (trim($res) == "yes" || trim($res) == "no" || trim($res) == "") {
            return (1);
        }
        return (-1);
    }
952336
public static function validation($name = false, $value = false) {
		if (!$name && !$value) {
			return self::$validate->getAll();
		}

		return self::$validate->validate($name, $value);
	}
181773
public function validate($value)
    {
        $return = new ValidateResult($value, false);
        //validator ->
        //return    ->
        $successValidated = [];

        foreach ($this->{$this->anyOfProperty} as $validator) {
            $validatorReturn = $validator->validate($value);

            if ($validatorReturn->status) {
                //push to successValidated list
                $successValidated[] = (object)[
                    'validator' => $validator,
                    'return'    => $validatorReturn
                ];
            }
        }

        if ((
                $this->requiredCountOfAnyOf === null
                && count($successValidated) > 0
            ) || (
                $this->requiredCountOfAnyOf !== null
                && count($successValidated) === $this->requiredCountOfAnyOf
            )
        ) {
            //Use first in list
            $return = $successValidated[0]->return;
            return $this->validateCommon($value, $return);
        }

        //error
        $return->errorObject = new IncorrectParametersException([
            [
                'type' => static::getType(),
                'failure' => $this->anyOfProperty
            ]
        ]);

        unset($successValidated);

        return $return;
    }
750612
function Check($value)
    {
        $this->SetValue($value);
        $required = $this->GetRequiredValidator();
        if ($required && !$required->Check($value))
        {
            $this->checkFailed = true;
            return false;
        }
        return parent::Check($value);
    }