<commit_before>//
//  BorderedTextField.swift
//  DCKit
//
//  Created by <NAME> on 16/02/15.
//  Copyright (c) 2015 <NAME> (<EMAIL>). All rights reserved.
//

import UIKit

/// Border is red if selected
@IBDesignable
public class DCMandatoryTextField: DCBorderedTextField {
    
    override public var selected: Bool {
        didSet {
            updateColor()
        }
    }
   
    @IBInspectable
    public var highlightedBorderColor: UIColor = UIColor.redColor() {
        didSet {
            updateColor()
        }
    }
    
    @IBInspectable
    public var isMandatory: Bool = true
    
    // MARK: - Build control
    
    override public func customInit() {
        super.customInit()
        
        updateColor()
        isValid()
    }
    
    // MARK: - Initializers
    
    // IBDesignables require both of these inits, otherwise we'll get an error: IBDesignable View Rendering times out.
    // http://stackoverflow.com/questions/26772729/ibdesignable-view-rendering-times-out
    
    override public init(frame: CGRect) {
        super.init(frame: frame)
    }
    
    required public init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
    }
    
    // MARK: - Build control
    
    override public func configurePlaceholder() {
        
    }
    
    // MARK: - Validation
    
    /// Checks if the field's value is valid. Can be overriden by subclasses.
    /// :return: True, if the field is mandatory and value is not empty.
    public func isValid() -> Bool {
        if isMandatory {
            let valid = !(text ?? "").isEmpty
            selected = !valid<commit_msg>- Added Login and Signup view controllers. - Added Reset password functionality. - Implemented validation.<commit_after>//
//  BorderedTextField.swift
//  DCKit
//
//  Created by <NAME> on 16/02/15.
//  Copyright (c) 2015 <NAME> (<EMAIL>). All rights reserved.
//

import UIKit

/// Border is red if selected
@IBDesignable
public class DCMandatoryTextField: DCBorderedTextField {
    
    override public var selected: Bool {
        didSet {
            updateColor()
        }
    }
   
    @IBInspectable
    public var highlightedBorderColor: UIColor = UIColor.redColor() {
        didSet {
            updateColor()
        }
    }
    
    @IBInspectable
    public var isMandatory: Bool = true
    
    // MARK: - Build control
    
    override public func customInit() {
        super.customInit()
        
        updateColor()
        isValid()
    }
    
    // MARK: - Initializers
    
    // IBDesignables require both of these inits, otherwise we'll get an error: IBDesignable View Rendering times out.
    // http://stackoverflow.com/questions/26772729/ibdesignable-view-rendering-times-out
    
    override public init(frame: CGRect) {
        super.init(frame: frame)
    }
    
    required public init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
    }
    
    // MARK: - Build control
    
    override public func configurePlaceholder() {
        
    }
    
    // MARK: - Validation
    
    /// Checks if the field's value is valid. Can be overriden by subclasses.
    ///
    /// :return: True, if the field is mandatory and value is not empty.
    public func isValid() -> Bool {
        if isMandatory {
            let valid = !(text ?? "").isEmpty
            selected = !valid
{'fraction_non_alphanumeric': 0.09800417039022938, 'fraction_numerical': 0.010723860589812333, 'mean_word_length': 1.9430324276950044, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, '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': '7581389', 'n_tokens_mistral': 1029, 'n_tokens_neox': 970, 'n_words': 283}