<commit_before><?php namespace EternalSword\LPress;

use Illuminate\Support\Facades\Lang;

class CustomValidator extends \Illuminate\Validation\Validator {

	protected $implicitRules = array(
		'Required',
		'RequiredWith',
		'RequiredWithout',
		'RequiredIf',
		'Accepted',
		'Bool',
		'RecordExists',
		'Same'
	);

	protected function doReplacements($message, $attribute, $rule, $parameters) {
		$message = str_replace(':attribute', "<span class='label'>" . $this->getAttribute($attribute) . "</span>", $message);
		if (isset($this->replacers[snake_case($rule)])) {
			$message = $this->callReplacer($message, $attribute, snake_case($rule), $parameters);
		}
		elseif (method_exists($this, $replacer = "replace{$rule}")) {
			$message = $this->$replacer($message, $attribute, $rule, $parameters);
		}
		return $message;
	}

	public static function getOwnMessages() {
		return Lang::get('l-press::validation');
	}

	public function validateBool($attribute, $value, $parameters) {
		return is_bool($value) || is_null($value);
	}

	public function validateRecordExists($attribute, $value, $parameters) {
		if(empty($value)) {
			return TRUE;
		}
		if(!is_numeric($value)) {
			return FALSE;
		}
		$record = Record::find($value);
		if(count($record) !== 1) {
			return FALSE;
		}
		if(!empty($parameters)) {
			$record->load('record_type');
			$record_type_slug = $parameters[0];
			$record_type = $record->record_type;<commit_msg>fix bool post check<commit_after><?php namespace EternalSword\LPress;

use Illuminate\Support\Facades\Lang;

class CustomValidator extends \Illuminate\Validation\Validator {

	protected $implicitRules = array(
		'Required',
		'RequiredWith',
		'RequiredWithout',
		'RequiredIf',
		'Accepted',
		'Bool',
		'RecordExists',
		'Same'
	);

	protected function doReplacements($message, $attribute, $rule, $parameters) {
		$message = str_replace(':attribute', "<span class='label'>" . $this->getAttribute($attribute) . "</span>", $message);
		if (isset($this->replacers[snake_case($rule)])) {
			$message = $this->callReplacer($message, $attribute, snake_case($rule), $parameters);
		}
		elseif (method_exists($this, $replacer = "replace{$rule}")) {
			$message = $this->$replacer($message, $attribute, $rule, $parameters);
		}
		return $message;
	}

	public static function getOwnMessages() {
		return Lang::get('l-press::validation');
	}

	public function validateBool($attribute, $value, $parameters) {
		if($value == 'on') $value = TRUE;
		if($value == 'off') $value = FALSE;
		return is_bool($value) || is_null($value);
	}

	public function validateRecordExists($attribute, $value, $parameters) {
		if(empty($value)) {
			return TRUE;
		}
		if(!is_numeric($value)) {
			return FALSE;
		}
		$record = Record::find($value);
		if(count($record) !== 1) {
			return FALSE;
		}
		if(!empty($parameters)) {
			$record->load('record_type');
			$record_type_slug = $parameters[0];
			$record_type = $record->record_type;
{'fraction_non_alphanumeric': 0.17835262083049694, 'fraction_numerical': 0.0013614703880190605, 'mean_word_length': 5.27991452991453, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4597375', 'n_tokens_mistral': 1042, 'n_tokens_neox': 962, 'n_words': 186}