Subject: [netmod] range/length and pattern statements

From: Andy Bierman <[email-masked]>
Date: Sat, 05 Jul 2008 09:26:34 -0700

Hi,

I noticed that the range statement in 8.1.3 clearly says
how to deal with multiple ranges in the typedef chain.

    If a value restriction is applied to an already
    restricted type, the new restriction MUST be equal or more limiting,
    that is raising the lower bounds, reducing the upper bounds, removing
    explicit values or ranges, or splitting ranges into multiple ranges
    with intermediate gaps.

An example in the draft might be good:

   typedef my-base-str-type {
     type my-base-str-type {
       length "1..255";
     }
   }

   typedef my-str-type {
     description "Valid range refinement";
     type my-base-str-type {
       length "11 | 42";
     }
   }

   typedef my-str-type {
     description "Invalid range refinement";
     type my-base-str-type {
       length "1..999";
     }
   }

Another example in 8.2.3 showing the relative 'min' or 'max' would be good:

     type my-base-str-type {
       length "42 .. max";   // 42 .. 255
     }

The pattern statement in 8.3.4 does not mention typedef chain
processing at all, which needs to be fixed.  Unlike range/length,
the pattern expressions are not validated against each other.
Instead, ALL the patterns in the typedef chain are logically ANDed
together, when validating a value against its data type.
Disjoint expressions (e.g., "[1-9]"  and "[a-z]") always
produce a negative result during evaluation.
This may be a data model bug, but is not a YANG error.

An example like the one above would be good in 8.3.5. (TBD)

Andy

_______________________________________________
netmod mailing list
[email-masked]
https://www.ietf.org/mailman/listinfo/netmod

---

From: Andy Bierman <[email-masked]>
Date: Sat, 05 Jul 2008 10:04:08 -0700

> An example in the draft might be good:

An example without cut-and-paste bugs would be better :-)

>   typedef my-base-str-type {
            ^^^^^^^^^^^^^^^^   string

Andy

---

From: Martin Bjorklund <[email-masked]>
Date: Sun, 06 Jul 2008 22:27:45 +0200 (CEST)

Hi,

>      description "Invalid range refinement";

I added this, to 8.3.3 since it shows length refinements, and I also
added:

  typedef my-base-int32-type {
      type int32 {
          range "1..4 | 10..20";
      }
  }

  type my-base-int32-type {
      // legal range restriction
      range "11..max"; // 11..20
  }

  type int32 {
      // illegal range restriction
      range "11..100";
  }

to 8.1.4.

> processing at all, which needs to be fixed.

The text says in 8.3.4:

   It [pattern] is used to restrict the built-in type "string", or
   types derived from "string", to values that completely matches the
   pattern.

Isn't it clear that the word "restrict" means that the value space is
not extended?

> Unlike range/length,

Whatabout this (useless) example:

  typedef my-str {
      type string {
          pattern "a|c|e";
      }
  }

  typedef my-str2 {
      type my-str {
          pattern "a-d";
      }
  }

  The value space of the type "my-str2" consists of the strings "a"
  and "c".

A useful example could be:

  typedef loopback-ipv4-address {
      type inet:ipv4-address {
          pattern "127.*";
      }
  }

/martin

---

From: Andy Bierman <[email-masked]>
Date: Sun, 06 Jul 2008 21:10:28 -0700

>       // illegal range restriction

Note that without change control rules, and I were allowed to
remove the range-stmt from 'my-base-int32-type', then the
relative value of 'max' would change silently
(and not be detected by 'diff').

(Couldn't help throwing that one in :-)

> Isn't it clear that the word "restrict" means that the value space is

It would be more clear if the text said that
all patterns in the typedef chain must match in
order for a string to be considered valid content
for a data type.

(Is the term 'typedef chain' defined?)

Is is really important that DM writers know
how YANG data types work, so some extra
examples here is better than too few examples.

>   The value space of the type "my-str2" consists of the strings "a"

fine.

>   typedef loopback-ipv4-address {

very fine.

Andy

---

From: Ladislav Lhotka <[email-masked]>
Date: Mon, 07 Jul 2008 11:57:17 +0200

> Isn't it clear that the word "restrict" means that the value space is

It should say explicitly that the regexps are ANDed. Actually, is it
possible to specify multiple pattern statements within the same typedef?
XSD datatype library supports this - they are ANDed, too.

Lada

-- 
Ladislav Lhotka, CESNET
PGP Key ID: E74E8C0C

---

From: Juergen Schoenwaelder <[email-masked]>
Date: Mon, 7 Jul 2008 12:31:59 +0200

> XSD datatype library supports this - they are ANDed, too.

We discussed this but then I think we did not really see the need for
this feature. The more complicated pattern we have so far are
typically OR combinations rather than AND combinations.

/js

-- 
Juergen Schoenwaelder           Jacobs University Bremen gGmbH
Phone: +49 421 200 3587         Campus Ring 1, 28759 Bremen, Germany
Fax:   +49 421 200 3103         <http://www.jacobs-university.de/>
_______________________________________________
netmod mailing list
[email-masked]
https://www.ietf.org/mailman/listinfo/netmod

---

From: Ladislav Lhotka <[email-masked]>
Date: Mon, 07 Jul 2008 14:10:18 +0200

> typically OR combinations rather than AND combinations.

For example, the pattern for ipv6-address in
draft-schoenw-netmod-yang-types-00 is not correct. The alternative for
shortened address is (omitting the scope part)

    '(([0-9a-fA-F]{1,4}:)*([0-9a-fA-F]{1,4}))*(::)'
+   '(([0-9a-fA-F]{1,4}:)*([0-9a-fA-F]{1,4}))*'

but this allows any number of 16-bit blocks to the left and to the right
of the double colon, which is wrong.

Both the full and shortened form of an IPv6 address can be restricted
together by

    '([0-9a-fA-F]{0,4}:){0,7}[0-9a-fA-F]{0,4}'

    AND

    '(([0-9a-fA-F]+:){7}[0-9a-fA-F]+)|(([0-9a-fA-F]+:)*[0-9a-fA-F]+)?::'
+   '(([0-9a-fA-F]+:)*[0-9a-fA-F]+)?'

A single-expression alternative can be derived from the ABNF in RFC 3986
(it's used in pyang), but it would be prohibitively long and
complicated.

Lada

-- 
Ladislav Lhotka, CESNET
PGP Key ID: E74E8C0C

---

From: Juergen Schoenwaelder <[email-masked]>
Date: Mon, 14 Jul 2008 11:19:24 +0200

> (it's used in pyang), but it would be prohibitively long and

I see your point. I leave this particular type definition unchanged
since we first need to figure out whether we want to add multiple
ANDed pattern to YANG.

/js