String

Creation

class User {
   public name: string;
}

const USER_META = new ObjectMeta({
   builder: User,
   fields: {
      name: new StringField(),
   }
});

const values = [
   {
      name: `Vasya`
   },
   {
      name: 12
   },
];

const result = JTC.convert({
   id: `String`,
   meta: new ObjectArrayMeta({ meta: USER_META }),
   values,
});

const log = JTC.log.asString(result.tree);

console.log(result.converted.all);
/* 1 (EXCLUDED) -> {...} | Validation failed for all fields
   1 (EXCLUDED) -> name -> 12 | Expected string, but got number */
console.log(log);

Validation

Enum

Allows to check that value is a member of specific enum

Min / Max

Allows to check that string have a specific length

Pattern

Allows to check that string matches specific pattern

Last updated