[scala] implement schema type rules