Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added ClassesDiagram.graffle
Binary file not shown.
3 changes: 3 additions & 0 deletions MUKit/MUCore/MUCore.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#ifndef MUKitTest_MUCore_h
#define MUKitTest_MUCore_h

// Base
#import "MUKitDefines.h"
#import "MUHelper.h"
#import "MUWeakRef.h"
Expand All @@ -17,9 +18,11 @@
#import "MUPair.h"
#import "MUHelper.h"
#import "MUFetchable.h"

// Validators
#import "MUValidator.h"
#import "MUValidationGroup.h"

// Formatters
#import "MUCreditCardNumberFormatter.h"
#import "MUPhoneNumberFormatter.h"
Expand Down
98 changes: 74 additions & 24 deletions MUKit/MUCore/MUInputTextFilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,64 +8,114 @@

#import <Foundation/Foundation.h>

//==============================================================================
//==============================================================================
//==============================================================================
/// text filter : base class
/**
`MUInputFilter` is an `NSObject` that used for filtering input info in text fields and text views.

@warning It's base class and should be subclassed for implenting some specified filters

*/
@interface MUInputFilter : NSObject

///-------------------------------
/// @name Main filter Methods
///-------------------------------

/**
Should return `YES` if replacementString correspons to filter allowed input.
*/
- (BOOL) filterText:(id)inputTextField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string;

@end

//==============================================================================
//==============================================================================
//==============================================================================
/// text with only number
/**
`MUInputFilterNumbreValue` is an `MUInputFilter` that allows to input only numbers.
*/
@interface MUInputFilterNumbreValue : MUInputFilter

///-------------------------------
/// @name Main filter Methods
///-------------------------------

@end

//==============================================================================
//==============================================================================
//==============================================================================
/// text with only numbers, numbers value has max
/**
`MUInputFilterNumbreValueWithMaxLengthText` is an `MUInputFilterNumbreValue` that allows to input only numbers and input string should be less than specified maximum length.
*/
@interface MUInputFilterNumbreValueWithMaxLengthText : MUInputFilterNumbreValue

@property (nonatomic, assign) NSUInteger maxLengthText;

///-------------------------------
/// @name Initialization Input Filter Methods
///-------------------------------

/**
Creates and initializes an `MUInputFilterNumbreValueWithMaxLengthText` object with the specified maximum text's length.

@param maximum length of allowed input text

@return The newly-initialized Input Filter
*/
- (id)initWithMaxLengthText:(NSUInteger) aMaxLengthText;

@end

//==============================================================================
//==============================================================================
//==============================================================================
/// text with only letters
/**
`MUInputFilterLetterValue` is an `MUInputFilter` that allows to input only letters.
*/
@interface MUInputFilterLetterValue : MUInputFilter

///-------------------------------
/// @name Main filter Methods
///-------------------------------

@end

//==============================================================================
//==============================================================================
//==============================================================================
/// text with only letters, text has limited the length
/**
`MUInputFilterLetterValueWithMaxLengthText` is an `MUInputFilterLetterValue` that allows to input only letters and input string should be less than specified maximum length.
*/
@interface MUInputFilterLetterValueWithMaxLengthText : MUInputFilterLetterValue

@property (nonatomic, assign) NSUInteger maxLengthText;

///-------------------------------
/// @name Initialization Input Filter Methods
///-------------------------------

/**
Creates and initializes an `MUInputFilterLetterValueWithMaxLengthText` object with the specified maximum text's length.

@param maximum length of allowed input text

@return The newly-initialized Input Filter
*/
- (id)initWithMaxLengthText:(NSUInteger) aMaxLengthText;

@end

//==============================================================================
//==============================================================================
//==============================================================================
/// text has limited the length
/**
`MUInputFilterStringWithMaxLengthText` is an `MUInputFilter` that allows to input any characters and input string should be less than specified maximum length.
*/
@interface MUInputFilterStringWithMaxLengthText : MUInputFilter

@property (nonatomic, assign) NSUInteger maxLengthText;

///-------------------------------
/// @name Initialization Input Filter Methods
///-------------------------------

/**
Creates and initializes an `MUInputFilterStringWithMaxLengthText` object with the specified maximum text's length.

@param maximum length of allowed input text

@return The newly-initialized Input Filter
*/
- (id)initWithMaxLengthText:(NSUInteger) aMaxLengthText;

@end
Expand Down
46 changes: 12 additions & 34 deletions MUKit/MUCore/MUInputTextFilter.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@

#import "MUInputTextFilter.h"

//==============================================================================
//==============================================================================
//==============================================================================
/// text filter : base class
#pragma mark - MUInputFilter

@implementation MUInputFilter

- (BOOL) filterText:(id)inputTextField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
Expand All @@ -21,10 +19,8 @@ - (BOOL) filterText:(id)inputTextField shouldChangeCharactersInRange:(NSRange)ra

@end

//==============================================================================
//==============================================================================
//==============================================================================
/// text with only number
#pragma mark - MUInputFilterNumbreValue

@implementation MUInputFilterNumbreValue

//==============================================================================
Expand Down Expand Up @@ -53,16 +49,12 @@ - (BOOL) filterText:(id)inputTextField shouldChangeCharactersInRange:(NSRange)ra

@end

//==============================================================================
//==============================================================================
//==============================================================================
/// text with only numbers, numbers value has max and min
#pragma mark - MUInputFilterNumbreValueWithMaxLengthText

@implementation MUInputFilterNumbreValueWithMaxLengthText

//==============================================================================
@synthesize maxLengthText;

//==============================================================================
- (id) initWithMaxLengthText:(NSUInteger)aMaxLengthText
{
self = [super init];
Expand All @@ -73,7 +65,6 @@ - (id) initWithMaxLengthText:(NSUInteger)aMaxLengthText
return self;
}

//==============================================================================
- (BOOL) filterText:(id)inputTextField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
BOOL result = NO;
Expand All @@ -99,13 +90,10 @@ - (BOOL) filterText:(id)inputTextField shouldChangeCharactersInRange:(NSRange)ra

@end

//==============================================================================
//==============================================================================
//==============================================================================
/// text with only letters
#pragma mark - MUInputFilterLetterValue

@implementation MUInputFilterLetterValue

//==============================================================================
- (BOOL) filterText:(id)inputTextField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
BOOL result = NO;
Expand All @@ -132,16 +120,12 @@ - (BOOL) filterText:(id)inputTextField shouldChangeCharactersInRange:(NSRange)ra

@end

//==============================================================================
//==============================================================================
//==============================================================================
/// text with only letters, text has limited the length
#pragma mark - MUInputFilterLetterValueWithMaxLengthText

@implementation MUInputFilterLetterValueWithMaxLengthText

//==============================================================================
@synthesize maxLengthText;

//==============================================================================
- (id) initWithMaxLengthText:(NSUInteger)aMaxLengthText
{
self = [super init];
Expand All @@ -152,7 +136,6 @@ - (id) initWithMaxLengthText:(NSUInteger)aMaxLengthText
return self;
}

//==============================================================================
- (BOOL) filterText:(id)inputTextField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
BOOL result = NO;
Expand All @@ -178,16 +161,12 @@ - (BOOL) filterText:(id)inputTextField shouldChangeCharactersInRange:(NSRange)ra

@end

//==============================================================================
//==============================================================================
//==============================================================================
/// text has limited the length
#pragma mark - MUInputFilterStringWithMaxLengthText

@implementation MUInputFilterStringWithMaxLengthText

//==============================================================================
@synthesize maxLengthText;

//==============================================================================
- (id) initWithMaxLengthText:(NSUInteger)aMaxLengthText
{
self = [super init];
Expand All @@ -198,7 +177,6 @@ - (id) initWithMaxLengthText:(NSUInteger)aMaxLengthText
return self;
}

//==============================================================================
- (BOOL) filterText:(id)inputTextField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
BOOL result = NO;
Expand Down
Loading