Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

44 lines (32 sloc) 1.06 kb
//
// US2ConditionRegex.m
// US2FormValidationFramework
//
// Created by Jack Qiu on 1/12/13.
// Copyright (c) 2013 ustwo™. All rights reserved.
//
#import "US2ConditionRegex.h"
@implementation US2ConditionRegex
- (US2ConditionRegex *) initWithRegex:(NSString *)regex {
self = [self init];
if (self != nil) self.regex = regex;
return self;
}
- (BOOL)check:(NSString *)string {
if (nil == self.regex) return NO;
if (nil == string)
string = [NSString string];
NSError *error = NULL;
NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:self.regex options:0 error:&error];
NSUInteger numberOfMatches = [regex numberOfMatchesInString:string options:0 range:NSMakeRange(0, string.length)];
return numberOfMatches == 1;
}
#pragma mark - Allow violation
- (BOOL)shouldAllowViolation {
return YES;
}
#pragma mark - Localization
- (NSString *) createLocalizedViolationString {
return US2LocalizedString(@"US2KeyConditionViolationRegex", nil);
}
@end
Jump to Line
Something went wrong with that request. Please try again.