Skip to content

Validation Interface - A validation interface based on a text specification.

License

Notifications You must be signed in to change notification settings

leohinterlang/valFace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ValFace

ValFace is a validation interface that checks input formatting and value constraints based on a text specification. Generated as the next logical step following the parsing of command line arguments (see: ArgFace), validation is an essential part of many applications. This project attempts to address this issue using a standard text specification.

Example:

private final String usageText = "guess <president> <year-elected>";

private final String[] valText = {
    "Values:",
        "<president> String = Lincoln | Washington | Jefferson ;",
        "<year-elected> Date = 1789 .. this.year;"
 };

ValFace valFace = ValPrototype.create(valText, this);
if (valFace == null) {
    return false;
}

Dates

Date specifications allow the use of common phrases to produce a particular date. Although in English, phrases such as "next week" or "last April" are imprecise, this implementation imposes a strict adherence to their meaning. These are relative terms associated with the current date and as such, their definition must be clear.

The basic date specification uses the ISO-8601 standard format.

<year>-<month>-<day>
The specified date. ex: 2014-09-18
<yyyy><mm><dd>
Without the dashes: 4 digit year, 2 digit month and day. ex: 20140918
Other basic date specifications include the following:
today
The current date. ex: 2014-09-18
tomorrow
The date after today. ex: 2014-09-19
yesterday
The date before today. ex: 2014-09-17
[this.]week
The Monday of the current week. ex: 2014-09-15
last.week
The Monday of the previous week. ex: 2014-09-08
next.week
The Monday of the following week. ex: 2014-09-22
end.[this.]week
[this.]week.end
The Sunday of the current week. ex: 2014-09-21

A week is defined as follows:

  • There are 5 weekdays; Monday, Tuesday, Wednesday, Thursday and Friday.

  • There are 2 weekend days; Saturday and Sunday.

  • The beginning of the week is Monday.

  • The end of the week is Sunday.

  • Each week is bracketed from Monday through Sunday.

  • The term "this.week" refers to the enclosing week.

  • The term "last.week" refers to days enclosed in the previous week.

  • The term "next.week" refers to days enclosed in the following week.

  • today or now - Today's date.

    today => 2014-09-18

  • next.year - January 1st of the next year.

  • this.year - January 1st of the current year.

  • last.year - January 1st of the previous year.

  • next.month - The 1st of the next month.

    next.month => 2014-10-01

  • next. - The 1st of the named month.

    next.September => 2015-09-01

  • next.week - The Monday of the next week.

  • next.

  • last.year

  • last.month

  • last.

  • last.week

  • last.

  • this.year

  • this.month

  • this.

  • this.week

  • this.

  • .plus..year(s)

  • .plus..month(s)

  • .plus..week(s)

  • .plus..day(s)

  • .minus..year(s)

  • .minus..month(s)

  • .minus..week(s)

  • .minus..day(s)

About

Validation Interface - A validation interface based on a text specification.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published