Question: So it should work like that

squareDigits("a22b") on "a44b"

squareDigits("a9b2") on "a81b4"

What I have got so far :

```
public class Code {
    public static void main(String[] args) {
        String ok = "a2b9";
        System.out.println(squareDigits(ok)); // "a81b4"
    }

  public static String squareDigits(String s) {
        char[] pena = s.toCharArray();
        int aboba;
        for (char c : pena) {
            if (Character.isDigit(c)) {
                String s1 = Character.toString(c);
                int b = Integer.parseInt(s1);
                aboba = b * b;
                System.out.println(aboba);
            }
        }
        return "";
        }
    }

```

Im only beginner and this would very help me out

Answer: 
What was the original problem was assigning the `EditContext`. It was necessary to access it but it can be done via `editForm.EditContext` as in the example below.

Working example <https://blazorrepl.com/repl/Glkmbcbr323MP1VS55>

Parent component:

```
<ChildComponent @ref="myTestComponent" testModel="testModel" />
<input type="button" @onclick="buttonClick" value="validate programmatically" />
<div>@testMessage</div>

@code {
    TestModel testModel = new TestModel();
    ChildComponent myTestComponent;
    string testMessage;

    void buttonClick()
    {
        testMessage = "not passed validation";

        if (myTestComponent.CanSubmit())
        {
            testMessage = "passed validation!";
        }
    }
}

```

Child component:

```
@if(testModel != null) {
    <EditForm @ref="editForm" Model="@testModel">
        <input type="text" @bind="testModel.Name" />
        <DataAnnotationsValidator />
        <ValidationSummary />
    </EditForm>
}

@code {
    [Parameter]
    public TestModel testModel
    {
        get; set;
    }

    EditForm editForm;

    public bool CanSubmit()
    {
        return editForm.EditContext.Validate();
    }
}

```
I have a different approach..
Your Parent have to look like this

```
<CascadingValue Value="testModel">
    <EditForm Model="testModel">
        <ChildComponent @ref="myTestComponent" />
        <ObjectGraphDataAnnotationsValidator />
        <ValidationMessage For="@(()=>testModel.Name)" />
        <br />
        <button type="submit">test</button>
    </EditForm>
</CascadingValue>

```

the only thing you need to do now in your Child is like this

```
@if (testModel != null)
{
  <InputText @bind-Value="testModel.Name" />
}

@code {

    [CascadingParameter]
    public TestModel testModel { get; set; }
}

```

I personally think it's less code...