On 2021-11-03, at 18:11, Mahesh Jethanandani <[email protected]> wrote: > > I believe if you remove the anchor characters ^ and & from the pattern > statement, the default value will work.
Indeed. And the reason is that YANG patterns are not PCRE/Javascript type regular expressions (which always require anchors unless used for searching), but W3C XSD type regular expressions, which are implicitly anchored. https://www.rfc-editor.org/rfc/rfc7950.html#section-9.4.5 Most people learn about PCRE/Javascript type regular expressions first, which is a source of a common misunderstanding of YANG (and, CDDL, for that matter) regular expressions. Grüße, Carsten > >> On Nov 3, 2021, at 12:06 PM, Olumide <[email protected]> wrote: >> […] >> leaf wibble { >> type string { >> pattern "^x$"; >> } >> default "x"; ### NOT OKAY >> } […] >> err : Value "x" does not satisfy the constraint "^x$" (range, length, or >> pattern). (/tmp:wibble) >> err : Module "tmp" parsing failed. >> >> >> Regards, >> >> - Olumide >> >> _______________________________________________ >> netmod mailing list >> [email protected] >> https://www.ietf.org/mailman/listinfo/netmod > > _______________________________________________ netmod mailing list [email protected] https://www.ietf.org/mailman/listinfo/netmod
