<commit_before>package com.taig.android.widget

import android.content.Context
import android.util.{AttributeSet, TypedValue}
import android.view.View
import android.widget.TextView
import com.taig.android._
import com.taig.android.conversion._
import com.taig.android.widget.validation.Type._
import com.taig.android.widget.validation.{Validator, Validatable}

/**
 * An EditText implementation that allows form validation
 */
class	EditText( context: Context, attributes: AttributeSet, style: Int )
extends	android.widget.EditText( context, attributes, style )
with	Validatable
{
	def this( context: Context, attributes: AttributeSet ) = this( context, attributes, android.R.attr.editTextStyle )

	def this( context: Context ) = this( context, null )

	val validation = new
	{
		private val array = context.obtainStyledAttributes( attributes, R.styleable.Widget_Validation, style, 0 )

		private val resolve = new
		{
			private val value = new TypedValue

			def enabled( index: Int ) = if( array.getValue( index, value ) )
			{
				value.`type` match
				{
					case TypedValue.TYPE_INT_BOOLEAN if value.resourceId == 0 => array.getBoolean( index, false )
					case _ => true
				}
			}
			else
			{
				false
			}

			def message( index: Int, resource: Int ) = Option( array.getString( index ) ).getOrElse
			{
				// Check if the main index received a string, otherwise fall back to default resource
				if( value.`type` == TypedValue.TYPE_STRING ) value.string else context.getString( resource )
			}
		}

		val icon = Option( array.getDrawable( R.styleable.Widget_Validation_icon ) )

		val alpha = new Alpha(
			resolve.enabled( R.styleable.Widget_Validation_alpha ),
			resolve.message( R.styleable.Widget_Validation_alphaMessage, R.string.validation_error_alpha )
		)

		val alphaDash = new AlphaDash(
			resolve.enabled( R.styleable.Widget_Validation_alphaDash ),
			resolve.message( R.styleable.Widget_Validation_alphaDashMessage, R.string.validation_error_alpha_dash )<commit_msg>Removed useless pattern matching guard<commit_after>package com.taig.android.widget

import android.content.Context
import android.util.{AttributeSet, TypedValue}
import android.view.View
import android.widget.TextView
import com.taig.android._
import com.taig.android.conversion._
import com.taig.android.widget.validation.Type._
import com.taig.android.widget.validation.{Validator, Validatable}

/**
 * An EditText implementation that allows form validation
 */
class	EditText( context: Context, attributes: AttributeSet, style: Int )
extends	android.widget.EditText( context, attributes, style )
with	Validatable
{
	def this( context: Context, attributes: AttributeSet ) = this( context, attributes, android.R.attr.editTextStyle )

	def this( context: Context ) = this( context, null )

	val validation = new
	{
		private val array = context.obtainStyledAttributes( attributes, R.styleable.Widget_Validation, style, 0 )

		private val resolve = new
		{
			private val value = new TypedValue

			def enabled( index: Int ) = if( array.getValue( index, value ) )
			{
				value.`type` match
				{
					case TypedValue.TYPE_INT_BOOLEAN => array.getBoolean( index, false )
					case _ => true
				}
			}
			else
			{
				false
			}

			def message( index: Int, resource: Int ) = Option( array.getString( index ) ).getOrElse
			{
				// Check if the main index received a string, otherwise fall back to default resource
				if( value.`type` == TypedValue.TYPE_STRING ) value.string else context.getString( resource )
			}
		}

		val icon = Option( array.getDrawable( R.styleable.Widget_Validation_icon ) )

		val alpha = new Alpha(
			resolve.enabled( R.styleable.Widget_Validation_alpha ),
			resolve.message( R.styleable.Widget_Validation_alphaMessage, R.string.validation_error_alpha )
		)

		val alphaDash = new AlphaDash(
			resolve.enabled( R.styleable.Widget_Validation_alphaDash ),
			resolve.message( R.styleable.Widget_Validation_alphaDashMessage, R.string.validation_error_alpha_dash )
{'fraction_non_alphanumeric': 0.09653961885656971, 'fraction_numerical': 0.0007522567703109327, 'mean_word_length': 4.1537467700258395, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '411701', 'n_tokens_mistral': 1316, 'n_tokens_neox': 1170, 'n_words': 311}