Sheerpower Logo

Input Validation Rules: DATE, TIME, PATTERN & Filters


Concise guide to Sheerpower's VALID() rules for dates, times, expressions, menus, routines, and powerful FILTER pipelines with RESTORE for multi-step validation.

What You’ll Learn

Sheerpower’s VALID(text$, vrules$) evaluates input against readable, composable rules like date dmony, required, pattern, and more. You can also pre-process text with filter steps (trim, case-change, replace/remove, etc.) and use restore to validate both the cleaned and the original input in one pass.

Quick Reference

  • DATE DMONY — DD-Mon-YY (e.g., 01-Jan-99)
  • DATE DMONCY — DD-Mon-CCYY (e.g., 01-Jan-2000)
  • FULLTIME — CCYYMMDD HHMMSS or YYMMDD HHMMSS
  • PATTERN — Matches a rule string (see Pattern)
  • REQUIRED — Non-empty, not just spaces
  • YES/NO — Only YES, NO, Y, or N (case-insensitive)
  • VRULES — Validates the rule set itself
  • PRINTMASK — Checks a print-format mask
  • EXPRESSION — Legal Sheerpower expression
  • CODE — Legal Sheerpower code block
  • MENU — Legal INPUT MENU description
  • ROUTINE — Routine name exists
  • FILTER — ltrim, rtrim, trim, ucase, lcase, replace, remove, change; plus restore
Return Values
Most rules return TRUE (1) or FALSE (0). The fulltime rule’s documentation below states FALSE (2) as the failure value; confirm in your build. Consistently check your return values when mixing rules.

DATE DMONY — DD-Mon-YY

Checks if text$ is a legal date in DD-Mon-YY format and returns TRUE (1) or FALSE (0).

// Expect: 1 text$ = '01-Jan-99' vrule$ = 'date dmony' print valid(text$, vrule$) end

DATE DMONCY — DD-Mon-CCYY

Checks if text$ is a legal date in DD-Mon-CCYY format and returns TRUE (1) or FALSE (0).

// Expect: 1 text$ = '01-Jan-2000' vrule$ = 'date dmoncy' print valid(text$, vrule$) end

FULLTIME — Date + Time

Checks if text$ is a legal date/time in either CCYYMMDD HHMMSS or YYMMDD HHMMSS format. Returns TRUE (1) or FALSE (2).

// Expect: 1 then 1 text$ = '20000122 010101' text2$ = '990122 010101' vrule$ = 'fulltime' print valid(text$, vrule$) print valid(text2$, vrule$) end

PATTERN — Custom Rule Match

Matches text$ against a rule string. See Section 6.5.4 PATTERN(str_expr1, str_expr2) for details.

REQUIRED — Non-blank

Returns TRUE if text$ is not null and not only spaces.

// Expect: 1 then 0 text$ = 'a b c d' text2$ = ' ' vrule$ = 'required' print valid(text$, vrule$) print valid(text2$, vrule$) end

YES/NO — Strict Yes/No

Returns TRUE if text$ is one of: YES, NO, Y, N.

// Expect: 1, 1, 0 text$ = 'yes' text2$ = 'n' text3$ = 'a' vrule$ = 'yes/no' print valid(text$, vrule$) print valid(text2$, vrule$) print valid(text3$, vrule$) end

VRULES — Validate Rule Set

Checks if a vrules$ string itself is a legal set of validation rules.

// Expect: 1 print valid('integer', 'vrules') end

PRINTMASK — Format Mask

Validates that text$ is a legal print mask.

// Expect: 1 text_str$ = '##.##' vrule$ = 'printmask' print valid(text_str$, vrule$) end

EXPRESSION — Sheerpower Expression

Returns TRUE if text$ is a legal Sheerpower expression.

// Expect: 1 then 0 text_str$ = 'total = a% + 30' text_str2$ = '##~-###' vrule$ = 'expression' print valid(text_str$, vrule$) print valid(text_str2$, vrule$) end

CODE — Sheerpower Code

Returns TRUE if text$ is syntactically legal Sheerpower code.

// Expect: false path taken a$ = "print 'hello, ' name$" if not valid(a$, 'code') then print 'false' end if end

MENU — INPUT MENU Description

Validates a menu description string for use with INPUT MENU.

// Expect: 1 text_str$ = '%multi,a,b,c' vrule$ = 'menu' print valid(text_str$, vrule$) end

ROUTINE — Existence Check

TRUE if the named routine exists; FALSE otherwise.

// Expect: 1 then 0 text$ = 'do_totals' text2$ = 'test_nos' vrule$ = 'routine' print valid(text$, vrule$) print valid(text2$, vrule$) end routine do_totals: private mytotal, desc$ mytotal = 15 desc$ = 'Test Totals' print desc$; mytotal end routine

FILTER — Clean, Transform, Validate

Filters modify text$ before validation. Chain multiple steps with semicolons. Supported filters:

  • ltrim$ — remove leading spaces
  • rtrim$ — remove trailing spaces
  • trim$ — remove leading and trailing spaces
  • ucase$ — uppercase
  • lcase$ — lowercase
  • replace — replace chars: old=new, old2=new2, ...
  • remove — remove listed chars from text$
  • change — complex remap (see CHANGE$)
  • restore — restore original (pre-filter) text for later validations in the same rule chain

Examples

FILTER + REMOVE / REPLACE / TRIM

// Expect: true, true, true text$ = 'abcd10' vrules$ = 'filter remove "10"; letters' text2$ = 'ab1cd1' vrules2$ = "filter replace '1'='e'; letters" text3$ = ' 1234 ' vrules3$ = "filter trim; number" if valid(text$, vrules$) then print 'true' if valid(text2$, vrules2$) then print 'true' if valid(text3$, vrules3$) then print 'true' end

FILTER + RESTORE

Use restore when you need a filtered check and then a second check on the original text later in the chain.

// Expect: true text$ = "123" vrule$ = "filter replace '1'='a'; restore; number" if valid(text$, vrule$) then print 'true' end
Design Tip
Problem: Real-world text is messy—extra spaces, odd casing, stray characters.
Solution: Normalize with filter (trim/case/remap), then restore to re-validate the untouched original when needed.
Efficiency: A single valid() call can handle a pipeline of filters and checks—fewer passes, clearer intent.
Takeaway: Treat validation as a readable pipeline: filter ...; restore; rule; rule; ...

Putting It Together

Combine rules with semicolons to form pipelines. Validate and transform in one statement, and lean on vrules to sanity-check complex rule strings at load time.

(Show/Hide Sheerpower Validation Rules Takeaways)
Hide Description

    

       


      

Enter or modify the code below, and then click on RUN

Looking for the full power of Sheerpower?
Check out the Sheerpower website. Free to download. Free to use.