►
From YouTube: Demo: ytt Schema Validations - August 24, 2022
Description
ytt maintainer, Varsha Munishwar, demonstrates the upcoming feature release of schema validations. Schema validations are the constraints that you can define on data values via annotations. Validations will ensure that data values are in expected range of values. This feature provides various out-of-the-box assertion rules as well as a way to write custom assertion-based rules.
A
Hello,
everyone,
as
we
all
know,
carl,
is
introducing
a
new
feature
in
its
tool
vit.
So
the
new
feature
is
called
schema
validations.
So
let's
get
started
with
the
demo.
What
are
validations
ytt
is
introducing
validations,
which
are
some
constraints
that
you
can
define
on
data
values
via
annotations
validation
will
ensure
that
data
values
in
expected
range
of
values.
A
So
in
the
beginning
we
have
yammer.
Let's
see
we
have
this
deployment.yaml
and
we
may
have
lots
of
yaml.
You
want
to
be
able
to
package
that
up
and
have
somebody
else
use
it.
So,
let's
see
first
thing
we
want
to
do
is
extract
the
values
from
the
cml.
A
A
Now
here
we
are
templating,
but
let's
say
someone
came
and
made
a
mistake
of
giving
value
type
wrong.
So
let's
see
bim
values.tml
and
here
instead
of
number
five
I
give
five.
A
Let's
see
what
happens
so
my
yaml
generated
shows
me
replicas
as
fine
so
wow.
This
is
well-formed
yaml,
but
this
is
not
a
valid
configuration
for
deployment
and
this
is
going
to
give
you
a
problem
at
the
time
of
deployment,
no
big
deal
if
it
is
simple
deployment.
But
what,
if
it's
part
of
larger
set
of
resources?
That's
a
problem,
and
you
want
to
find
it
sooner
so
for
this
we
came
up
with
schema
in
schema.
We
declare
variables,
we
give
default
values
and
we
infer
type
from
default.
A
A
The
value
is,
the
value
of
instances
is
automatically
get.
It
gets
inferred
so
here
in
schema
because
it
is
given
as
integer.
Now
I'm
getting
expected.
Integer
error.
A
This
is
how
schema
checks
for
types
and
tells
us
expected
integer,
okay,
but
now,
instead
of
now
here,
instead
of
giving
us
the
entire
yaml,
we
got
error
message
and
that's
like
pulling
the
error
towards
left.
Trying
to
avoid
going
through
half
succeeded
deployments
to
find
out
where
the
error
is
so
now
type
safety
is
what
schema
gave
us,
but
now,
let's
see,
let's
update
the
value
back
to
phi.
A
And
now
this
is
our
valid
yaml,
which
is
also
type
safe.
But
let's
say
let's
say
there
is
a
requirement
that
your
system
cannot
perform.
Well
with
less
number
of
resources
say
you
need
minimum
of
10
resource
10
instances,
and
then
you
go
and
update
in
schema
yaml
that
we
need
at
least
10.
A
A
So
this
is
where
validations
come
into
picture.
They
help
improve
the
user's
experience
by
catching
obvious
configuration
errors
before
deployment.
That's
pulling
the
error
towards
left.
Now
you
will
do
this
by
with
validations
in
schema
file.
So,
let's
see
currently,
this
feature
is
available
as
experimental,
so
we'll
first
ensure
that
we
have
correct
version
and
turn
on
the
validations.
So
to
do
it.
So
we
have
this
export
line
to
add,
and
this
make
sure
our
experimentation
is
extreme
by
experiment.
Validation
is
set
and
then
we'll
check
the
version.
Ytt
version
sorry
version
0.42.
A
Now,
let's
see,
let's
add
the
constraint
here,
how
to
add
this
constraint
can
cause
sorry
schema,
tml
and
just
add
one
line
over
here.
Schema
validation,
annotation
mean
equal
to
10,
and
now,
when
I
run
this,
it
gives
me
error
that
one
or
more
data
values
were
invalid
requires
instances
requires
a
value
greater
or
equal
to
10
fail
5,
so
5
is
less
than
10
and
which
is
the
value
which
we
gave
in
values.tml,
so
instance
is
5..
A
A
Let's
try
one
more
example.
So,
let's
see
as
an
author,
you
may
have
a
requirement
of
having
a
username
and
password
present
for
particular
storage.
I
can
provide
a
default,
but
I
want
user
to
set
user
name
and
password
values.
How
do
you
make
them?
Do
that
write?
A
validation
that
you
know
will
fail
with
a
default
value
for
that
we
will
add
this
kind
of
validation.
A
You
get
all
kinds
of
validation
errors
that
are
present
in
the
schema
and
values
file.
So
this
first
one
we
already
saw
that
5
is
less
than
10
and
it's
not
aligned
here.
Instances
requires
value
greater
than
or
equal
to
10
another
username
password
and
for
username
next
next
set
of
username
passwords.
So
so
two
couple
of
things
to
notice.
Here
we
learn
about
all
the
problems
at
once
and
not
like
one
after
other
one
after
other,
and
this
is
forcing
user
to
specify
value.
A
So,
let's,
let's
add
the
values
in
values.yaml
theme
and
installment.
I
added
a
few
instances:
215
storage,
aws
and
username
with
some
username
and
passwords.
So
in
that
case
now
this
is
working
now,
if
say,
we
have
some
default.
Values
are
null
say,
aws
and
gcs,
both
unknown,
and
what,
if
you
want
to
be
able
to
say
that
at
least
one
of
them
not
null?
You
need
to
specify
exactly
one
of
them.
For
this
we
have
another
type
of
validation
rule
out
of
the
box,
which
is
one
not
null.
So
let's
try
that.
A
So
I
have
this
schema
schema
data,
which
has
this
storage,
aws
and
gcs
with
schema
on
the
label
added,
because
what,
if
user
gives
both
of
them
aws
and
gcs,
none
and
and
like
they
are
they're,
not
level
values.
But
we
want
to
add
a
constraint
that
only
one
of
at
least
one
of
them
should
be
not
null.
So,
let's
see
what's
in
the
values,
file
values.
A
So
here
we
are
not
provided
and
it
any
value
for
aws
and
gcs.
And
let's
see
then
what
error
current
ytt
schema.
A
A
A
So
when
we
add
those
values
again
back
say,
let's
see
I
add
username
and
password.
A
That's
what
it
does
now.
It
gives
me
another
the
error
earlier
error,
which
is
min
length,
but
now
it
knows
that
one
of
the
storage
types
has
received
its
value,
so
username
and
password
is
there
available
and
that's
why
this
error
is
not
there.
But
now
we
have
this
constraint
that
the
user
has
to
have
some
username
and
password
values.
Present.
A
A
A
So
this
is
how
schema
validations
work,
and
so
we
have
other
thing
that
we
have
is
with
this
schema
validation
feature.
We
have
your
documentation,
that
is
on
the
website.
There
is
a
ytt
validations,
preview,
blog
post,
that
you
can
go
through
and
also
we
have
created
a
cheat
sheet
for
you.
Let
me
show
that
screen.
A
So
here
we
go
here:
we
have
the
schema
validation,
documentation
on
ytt
website.
You
go
here,
schema
validation.
It
shows
us
the
out
of
the
box
rules
and
some
details
about
it.
Few
examples
out
of
the
box
assertion,
rules
and
custom
assertion
best
rules.
A
This
is
the
preview
of
vitality,
validation,
blog
post
by
john-
and
this
is
the
validations
chit
chat
that
john
and
I
prepared
this-
gives
you
various
use
cases.
What
kind
of
validation
rules
you
can
apply
like
me
mean
len,
not
null,
and
all
of
these
and
their
respective
syntax,
along
with
examples.
A
So,
for
example,
we
have
already
seen
few
of
them
and
then
there
is
a
one-off
that
can
be
used
for
enumeration,
one,
not
null
that
we
already
saw,
which
is
for
exactly
one,
not
null.
A
So
when
null
skip
validations,
these
are
validations
overall
levels.
So
whenever
a
node
is
annotated
with
at
schema
on
the
level,
then
its
default
value
is
null
and
author
may
opt
up
to
short
circuit
validations
when
the
actual
value
is
null
using
this
when
skip
equal
to
true
and
the
last
one
we
are
seeing
today
is
conditionally
run
validations.
So
let
me
open
my.
A
My
terminal
window
again-
and
I
have
this
emar.yaml,
which
has
this
conditional
validation
added,
so
basically
is
load
balancer.
So
when
ease
load
balancer
is
called.
If
there
is
a
type
called
load
balancer,
then
the
name
must
be
given.
That's
my
custom
rule
you
want
to
add
so
the
name
must
be
given
is
satisfied
using
ascert
mean
length
one
and
we
are
checking.
If
name
is
present.
So,
let's
see
what's
in
the
values
file
right
now,
I
don't
have
here
name,
and
so,
when
I
run
this,
I
get
this
kind
of
error.
A
A
This
validation
works
and
the
value
is
rendered
so
yeah.
These
are
the
these
are
some
of
the
rules
that
schema
validation
adds
out
of
the
box,
and
there
are
certain
custom
rules
you
can
add
to
using
lambda
functions
and
yeah,
so
that's
it
for
today.
Let
us
know
if
you
have
any
questions.
We
are
reachable
through
slack
channel
as
well
as
in
the
community
meetings.