Skip to content

Commit

Permalink
Merge pull request #87 from valydia/feature_enforce_column_case
Browse files Browse the repository at this point in the history
Feature enforce column case
  • Loading branch information
LauraDamianTNA committed Nov 11, 2015
2 parents e95a5c5 + 98bdcb8 commit 88b0978
Show file tree
Hide file tree
Showing 4 changed files with 386 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,10 @@ case class Uuid4Rule() extends PatternRule("uuid4", Uuid4Regex)

case class PositiveIntegerRule() extends PatternRule("positiveInteger", PositiveIntegerRegex)

case class UpperCaseRule() extends PatternRule("upperCase", UpperCaseRegex)

case class LowerCaseRule() extends PatternRule("lowerCase", LowerCaseRegex)

case class IdenticalRule() extends Rule("identical") {

var lastValue: Option[String] = None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ trait SchemaParser extends RegexParsers
* XsdDateTimeExpr | XsdDateExpr | XsdTimeExpr |
* UkDateExpr | DateExpr | PartialUkDateExpr | PartialDateExpr |
* uuid4Expr |
* PositiveIntegerExpr)
* PositiveIntegerExpr | UpperCaseExpr | LowerCaseExpr)
*/
//TODO need to implement and add DateExpr, PartialDateExpr
lazy val singleExpr: PackratParser[Rule] = "SingleExpr" ::=
Expand All @@ -275,7 +275,7 @@ trait SchemaParser extends RegexParsers
xsdDateTimeExpr | xsdDateExpr | xsdTimeExpr |
ukDateExpr | partialUkDateExpr |
uuid4Expr |
positiveIntegerExpr) ^^ {
positiveIntegerExpr | upperCaseExpr | lowerCaseExpr) ^^ {
case explicitContext ~ rule =>
rule.explicitColumn = explicitContext
rule
Expand Down Expand Up @@ -475,6 +475,12 @@ trait SchemaParser extends RegexParsers
*/
lazy val positiveIntegerExpr: PackratParser[PositiveIntegerRule] = "PositiveIntegerExpr" ::= "positiveInteger" ^^^ PositiveIntegerRule()


lazy val upperCaseExpr: PackratParser[UpperCaseRule] = "UpperCaseExpr" ::= "upperCase" ^^^ UpperCaseRule()


lazy val lowerCaseExpr: PackratParser[LowerCaseRule] = "LowerCaseExpr" ::= "lowerCase" ^^^ LowerCaseRule()

/**
* [59] StringProvider ::= ColumnRef | StringLiteral
*/
Expand All @@ -501,6 +507,7 @@ trait SchemaParser extends RegexParsers
FileExistsRule(pathSubstitutions, enforceCaseSensitivePathChecks, s)
}


/**
* [62] ChecksumExpr ::= "checksum(" FileExpr "," StringLiteral ")" /* first arg is file expr, second arg is algorithm to use for checksum */
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ package object schema {

val UkDateRegex = """(((0[1-9]|(1|2)[0-9]|3[0-1])\/(0(1|3|5|7|8)|1(0|2)))|((0[1-9]|(1|2)[0-9]|30)\/(0(4|6|9)|11))|((0[1-9]|(1|2)[0-9])\/02))\/[0-9]{4}"""
val PositiveIntegerRegex = "[0-9]+"
val UpperCaseRegex = "^[\\p{Lu}\\p{N}\\p{P}\\s]*$" //"^[\\p{Lu}\\p{N}\\p{P}\\s]+$" if we ant to dismiss empty string
val LowerCaseRegex = "^[\\p{Ll}\\p{N}\\p{P}\\s]*$"
val UkDateFormat = "dd/MM/YYYY"
val PartUkDateRegex = """(([0\?][1-9\?])|([1-2\?][0-9\?])|([3\?][0-1\?])|\*)\/(January|February|March|April|May|June|July|August|September|October|November|December|\?|\*)\/([0-9\?]{4}|\*)"""

Expand Down
Loading

0 comments on commit 88b0978

Please sign in to comment.